@nylas/react 2.1.0 → 2.2.1
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/dist/cjs/connect.js +1 -0
- package/dist/cjs/elements.js +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/notetaker.js +62 -0
- package/dist/cjs/utils.js +11 -0
- package/dist/connect.d.ts +1 -0
- package/dist/elements.d.ts +1 -0
- package/dist/es/connect.js +279 -0
- package/dist/es/elements.js +1319 -0
- package/dist/es/index.js +281 -0
- package/dist/es/notetaker.js +5784 -0
- package/dist/es/utils.js +12396 -0
- package/dist/lib/connect/types.d.ts +1 -1
- package/dist/lib/connect/useNylasConnect.d.ts +2 -2
- package/dist/lib/connect.d.ts +1 -0
- package/dist/lib/elements/components.d.ts +975 -0
- package/dist/lib/elements.d.ts +1 -0
- package/dist/lib/index.d.ts +3 -6
- package/dist/lib/notetaker.d.ts +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/notetaker.d.ts +1 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +36 -16
- package/dist/add-circle-icon_2.entry-8c3bb0bb.cjs +0 -1
- package/dist/add-circle-icon_2.entry-a3daf6c4.js +0 -28
- package/dist/archive-icon.entry-46ad0ff3.cjs +0 -1
- package/dist/archive-icon.entry-d5141486.js +0 -18
- package/dist/arrow-icon.entry-1b89ce78.js +0 -18
- package/dist/arrow-icon.entry-f696de4f.cjs +0 -1
- package/dist/bold-icon.entry-7827cd4e.cjs +0 -1
- package/dist/bold-icon.entry-c117b4cf.js +0 -18
- package/dist/button-component_2.entry-8cd4c5f3.cjs +0 -1
- package/dist/button-component_2.entry-e68caa9b.js +0 -29
- package/dist/calendar-agenda-fill-icon_37.entry-52bdc8b3.js +0 -5234
- package/dist/calendar-agenda-fill-icon_37.entry-8c592cfa.cjs +0 -6
- package/dist/calendar-cancel-icon.entry-7facfa05.cjs +0 -1
- package/dist/calendar-cancel-icon.entry-f5f1d499.js +0 -18
- package/dist/calendar-check-icon.entry-55320137.js +0 -18
- package/dist/calendar-check-icon.entry-72108702.cjs +0 -1
- package/dist/calendar-icon.entry-afea361e.js +0 -18
- package/dist/calendar-icon.entry-f5c6730f.cjs +0 -1
- package/dist/checkbox-component.entry-5722d263.cjs +0 -1
- package/dist/checkbox-component.entry-89fa6edd.js +0 -54
- package/dist/checkbox-group_4.entry-30e8af17.cjs +0 -28
- package/dist/checkbox-group_4.entry-51f03009.js +0 -10014
- package/dist/checkmark-circle-icon.entry-ae11049d.cjs +0 -1
- package/dist/checkmark-circle-icon.entry-dfe67e22.js +0 -18
- package/dist/checkmark-icon_15.entry-4c3979db.js +0 -1415
- package/dist/checkmark-icon_15.entry-e59c0f53.cjs +0 -5
- package/dist/chevron-icon_3.entry-1f3c3ca6.js +0 -159
- package/dist/chevron-icon_3.entry-ea791750.cjs +0 -1
- package/dist/clock-icon_4.entry-172fed74.cjs +0 -1
- package/dist/clock-icon_4.entry-78878cb8.js +0 -48
- package/dist/constants-f51538ef-cd2a67c4.cjs +0 -1
- package/dist/constants-f51538ef-e0a5f026.js +0 -876
- package/dist/customParseFormat-b5d95b34-a6b6fcba.cjs +0 -1
- package/dist/customParseFormat-b5d95b34-ce80820c.js +0 -135
- package/dist/delete-icon.entry-a8c0bf03.cjs +0 -1
- package/dist/delete-icon.entry-cebdc90f.js +0 -18
- package/dist/document-refresh-icon.entry-2d9a529d.cjs +0 -1
- package/dist/document-refresh-icon.entry-8780a2b8.js +0 -18
- package/dist/feedbackSync-92220b42-fbebe1f9.cjs +0 -448
- package/dist/feedbackSync-92220b42-fd5f5610.js +0 -6048
- package/dist/folder-icon.entry-3e61ccca.cjs +0 -1
- package/dist/folder-icon.entry-6ffd5191.js +0 -18
- package/dist/forward-icon.entry-c7d88db8.cjs +0 -1
- package/dist/forward-icon.entry-c9c4bf5b.js +0 -18
- package/dist/globe-icon.entry-0b93cab8.cjs +0 -1
- package/dist/globe-icon.entry-7c0dca7b.js +0 -18
- package/dist/google-logo-icon_6.entry-deef91ee.js +0 -1765
- package/dist/google-logo-icon_6.entry-e25ce3e7.cjs +0 -2
- package/dist/google-meet-icon_5.entry-214347f0.cjs +0 -1
- package/dist/google-meet-icon_5.entry-f8b5a92a.js +0 -58
- package/dist/inbox-icon.entry-873062c3.js +0 -18
- package/dist/inbox-icon.entry-f08f2fd5.cjs +0 -1
- package/dist/index-025be398.js +0 -7187
- package/dist/index-c510313d-1318f67a.js +0 -289
- package/dist/index-c510313d-b0508eee.cjs +0 -1
- package/dist/index-f42fe591.cjs +0 -65
- package/dist/index.es-488bc919-d02dd50a.cjs +0 -7
- package/dist/index.es-488bc919-ea63a7e9.js +0 -2724
- package/dist/info-icon_2.entry-442b9097.cjs +0 -1
- package/dist/info-icon_2.entry-60fb8648.js +0 -37
- package/dist/input-component.entry-5898a52e.js +0 -96
- package/dist/input-component.entry-7274fd28.cjs +0 -1
- package/dist/input-dropdown_2.entry-4534436c.js +0 -255
- package/dist/input-dropdown_2.entry-9b72f637.cjs +0 -1
- package/dist/italic-icon.entry-62052cd8.js +0 -18
- package/dist/italic-icon.entry-9bdbbd37.cjs +0 -1
- package/dist/lib/elements/index.d.ts +0 -133
- package/dist/lib/elements/react-component-lib/createComponent.d.ts +0 -10
- package/dist/lib/elements/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/dist/lib/elements/react-component-lib/index.d.ts +0 -2
- package/dist/lib/elements/react-component-lib/interfaces.d.ts +0 -29
- package/dist/lib/elements/react-component-lib/utils/attachProps.d.ts +0 -9
- package/dist/lib/elements/react-component-lib/utils/case.d.ts +0 -2
- package/dist/lib/elements/react-component-lib/utils/dev.d.ts +0 -2
- package/dist/lib/elements/react-component-lib/utils/index.d.ts +0 -10
- package/dist/multi-select-dropdown.entry-77752d46.cjs +0 -1
- package/dist/multi-select-dropdown.entry-9c9d05c1.js +0 -133
- package/dist/nylas-booked-event-card_11.entry-32b2e9f1.js +0 -1410
- package/dist/nylas-booked-event-card_11.entry-4aba5146.cjs +0 -1
- package/dist/nylas-date-component_2.entry-6b058796.cjs +0 -1
- package/dist/nylas-date-component_2.entry-a869519f.js +0 -310
- package/dist/nylas-form-card.entry-5390459f.js +0 -75
- package/dist/nylas-form-card.entry-c2f34d73.cjs +0 -1
- package/dist/nylas-notification_2.entry-054392cf.cjs +0 -1
- package/dist/nylas-notification_2.entry-f46e88e5.js +0 -88
- package/dist/nylas-scheduler-editor.entry-40a48f47.js +0 -1854
- package/dist/nylas-scheduler-editor.entry-e29fdf07.cjs +0 -2
- package/dist/nylas-scheduling.entry-115b1752.js +0 -1002
- package/dist/nylas-scheduling.entry-79cb1d9c.cjs +0 -1
- package/dist/person-icon.entry-2cae306c.cjs +0 -1
- package/dist/person-icon.entry-fd668b89.js +0 -18
- package/dist/play-icon.entry-7fc3c0fd.js +0 -18
- package/dist/play-icon.entry-9989a520.cjs +0 -1
- package/dist/radio-button-group.entry-03385b5f.cjs +0 -1
- package/dist/radio-button-group.entry-9df82cd0.js +0 -58
- package/dist/react.cjs +0 -1
- package/dist/react.js +0 -164
- package/dist/refresh-icon.entry-310954ba.cjs +0 -1
- package/dist/refresh-icon.entry-c56e5623.js +0 -18
- package/dist/register-component-3acd57e7-5a79a90a.cjs +0 -1
- package/dist/register-component-3acd57e7-cb09c05e.js +0 -110
- package/dist/reply-all-icon.entry-32e0e000.js +0 -18
- package/dist/reply-all-icon.entry-68388f97.cjs +0 -1
- package/dist/reply-icon.entry-3ac2e736.js +0 -18
- package/dist/reply-icon.entry-e616a9a4.cjs +0 -1
- package/dist/sent-icon.entry-0622ed04.js +0 -18
- package/dist/sent-icon.entry-543eb3c4.cjs +0 -1
- package/dist/spam-icon.entry-74bcfd4f.js +0 -18
- package/dist/spam-icon.entry-e341ee3e.cjs +0 -1
- package/dist/star-icon.entry-864d2bf9.js +0 -18
- package/dist/star-icon.entry-c90d40f6.cjs +0 -1
- package/dist/stop-icon.entry-835908c5.js +0 -18
- package/dist/stop-icon.entry-ffc46b42.cjs +0 -1
- package/dist/textarea-component.entry-6adcf6a6.js +0 -58
- package/dist/textarea-component.entry-dae8eb5c.cjs +0 -1
- package/dist/toggle-switch.entry-5ee29867.cjs +0 -1
- package/dist/toggle-switch.entry-ff2ccb75.js +0 -51
- package/dist/translate-icon.entry-372dd808.js +0 -18
- package/dist/translate-icon.entry-5606067d.cjs +0 -1
- package/dist/trash-fill-icon.entry-01b4379e.js +0 -18
- package/dist/trash-fill-icon.entry-daed6c0a.cjs +0 -1
- package/dist/underline-icon.entry-2020ee64.cjs +0 -1
- package/dist/underline-icon.entry-464b900d.js +0 -18
- package/dist/utils-31933f5d-15041585.js +0 -17878
- package/dist/utils-31933f5d-1d4c81ab.cjs +0 -54
|
@@ -1,1854 +0,0 @@
|
|
|
1
|
-
var le = Object.defineProperty;
|
|
2
|
-
var ce = (r, t, n) => t in r ? le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
|
|
3
|
-
var P = (r, t, n) => (ce(r, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement, F as Fragment } from "./index-025be398.js";
|
|
5
|
-
import { N as NylasBaseProvider, c as createStore } from "./index-c510313d-1318f67a.js";
|
|
6
|
-
import { d as dataResponse, a as dayjs, u as utc, t as timezone, p as process, c as commonjsGlobal, b as debug, i as instance, B as Buffer, g as getCalendarRange } from "./utils-31933f5d-15041585.js";
|
|
7
|
-
import { X as Xr } from "./index.es-488bc919-ea63a7e9.js";
|
|
8
|
-
import { L as LANGUAGE_CODE, a as LANGUAGE_MAP, C as CONFIGURATION_EVENT_TYPE } from "./constants-f51538ef-e0a5f026.js";
|
|
9
|
-
import "@nylas/web-elements";
|
|
10
|
-
import "react";
|
|
11
|
-
import "@nylas/connect";
|
|
12
|
-
import "react/jsx-runtime";
|
|
13
|
-
import "react-dom";
|
|
14
|
-
class NylasIdentityRequestWrapper {
|
|
15
|
-
constructor(t) {
|
|
16
|
-
this.defaultAuthArgs = [], this.session = t;
|
|
17
|
-
}
|
|
18
|
-
setActiveGrantId(t) {
|
|
19
|
-
this.activeGrantId = t;
|
|
20
|
-
}
|
|
21
|
-
async request({ method: t, path: n, body: s, headers: a }) {
|
|
22
|
-
try {
|
|
23
|
-
const l = await this.session.fetch(`grants/me/${n}`, {
|
|
24
|
-
method: t,
|
|
25
|
-
headers: a ? new Headers(a) : void 0,
|
|
26
|
-
body: s,
|
|
27
|
-
...this.session.isMultiAccount() && this.activeGrantId ? { grant_id: this.activeGrantId } : {}
|
|
28
|
-
});
|
|
29
|
-
if (typeof l > "u")
|
|
30
|
-
throw new Error("Response is undefined");
|
|
31
|
-
return dataResponse(l);
|
|
32
|
-
} catch (l) {
|
|
33
|
-
let d = String(l);
|
|
34
|
-
return String(l).includes("Access token not found") && (d = "Session expired, please log in again. Redirecting...", setTimeout(() => {
|
|
35
|
-
localStorage.removeItem("grant"), localStorage.removeItem("user"), window.location.reload();
|
|
36
|
-
}, 1e3)), dataResponse(null, {
|
|
37
|
-
message: d
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async currentUser() {
|
|
42
|
-
const t = this.session.isMultiAccount() ? this.activeGrantId : void 0, n = await this.session.getProfile(t);
|
|
43
|
-
if (await this.session.isLoggedIn()) {
|
|
44
|
-
const a = (await this.session.fetch("grants/me", {
|
|
45
|
-
method: "GET",
|
|
46
|
-
...this.session.isMultiAccount() && this.activeGrantId ? { grant_id: this.activeGrantId } : {}
|
|
47
|
-
})).data;
|
|
48
|
-
if (!n || !a)
|
|
49
|
-
return null;
|
|
50
|
-
const l = a.email;
|
|
51
|
-
return {
|
|
52
|
-
id: n.sub,
|
|
53
|
-
email: l,
|
|
54
|
-
name: n.name,
|
|
55
|
-
provider: n.provider
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
async authenticationUrl(t) {
|
|
61
|
-
const n = (t == null ? void 0 : t.provider) || "google";
|
|
62
|
-
let a = this.defaultAuthArgs.find((l) => l.provider === n) || {};
|
|
63
|
-
return t && (a = { ...a, ...t }), this.session.auth(a);
|
|
64
|
-
}
|
|
65
|
-
setDefaultAuthArgs(t) {
|
|
66
|
-
this.defaultAuthArgs = t;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
dayjs.extend(utc);
|
|
70
|
-
dayjs.extend(timezone);
|
|
71
|
-
class NylasSchedulerConfigAPIConnector {
|
|
72
|
-
constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
|
|
73
|
-
this.groupEventsCache = /* @__PURE__ */ new Map(), this.CACHE_DURATION = 1 * 60 * 1e3, this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
|
|
74
|
-
}
|
|
75
|
-
async currentUser() {
|
|
76
|
-
return this.nylasApiRequest ? this.nylasApiRequest.currentUser() : (console.warn("Nylas API Request is not initialized"), null);
|
|
77
|
-
}
|
|
78
|
-
async getCalendars() {
|
|
79
|
-
var a;
|
|
80
|
-
if (!this.nylasApiRequest)
|
|
81
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
82
|
-
message: "Error fetching calendars: Nylas API Request is not initialized"
|
|
83
|
-
});
|
|
84
|
-
const t = [];
|
|
85
|
-
let n = null;
|
|
86
|
-
const s = 50;
|
|
87
|
-
do {
|
|
88
|
-
const [l, d] = await this.nylasApiRequest.request({
|
|
89
|
-
method: "GET",
|
|
90
|
-
path: `calendars?limit=${s}${n ? `&page_token=${n}` : ""}`
|
|
91
|
-
});
|
|
92
|
-
if (d)
|
|
93
|
-
return dataResponse(null, {
|
|
94
|
-
message: "Error fetching calendars: " + d.message
|
|
95
|
-
});
|
|
96
|
-
if (Xr(l))
|
|
97
|
-
return dataResponse(null, {
|
|
98
|
-
message: "Error fetching calendars: " + ((a = l.error) == null ? void 0 : a.message)
|
|
99
|
-
});
|
|
100
|
-
t.push(...l.data), n = l.next_cursor || null;
|
|
101
|
-
} while (n);
|
|
102
|
-
return this.nylasSchedulerConfigStore.state.calendars = t, dataResponse(t);
|
|
103
|
-
}
|
|
104
|
-
async getConfigurationById(t, n = !1) {
|
|
105
|
-
var l;
|
|
106
|
-
if (!this.nylasApiRequest)
|
|
107
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
108
|
-
message: "Error fetching configuration: Nylas API Request is not initialized"
|
|
109
|
-
});
|
|
110
|
-
if (!n) {
|
|
111
|
-
const d = this.nylasSchedulerConfigStore.state.configurations.find((c) => c.id === t);
|
|
112
|
-
if (d)
|
|
113
|
-
return this.nylasSchedulerConfigStore.state.selectedConfiguration = d, dataResponse(d);
|
|
114
|
-
}
|
|
115
|
-
const [s, a] = await this.nylasApiRequest.request({
|
|
116
|
-
method: "GET",
|
|
117
|
-
path: `scheduling/configurations/${t}`
|
|
118
|
-
});
|
|
119
|
-
return a ? dataResponse(null, {
|
|
120
|
-
message: "Error fetching configuration: " + a.message
|
|
121
|
-
}) : Xr(s) ? dataResponse(null, {
|
|
122
|
-
message: "Error fetching configuration: " + ((l = s.error) == null ? void 0 : l.message)
|
|
123
|
-
}) : (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));
|
|
124
|
-
}
|
|
125
|
-
async getConfigurations(t) {
|
|
126
|
-
var l;
|
|
127
|
-
if (!this.nylasApiRequest)
|
|
128
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
129
|
-
message: "Error fetching configurations: Nylas API Request is not initialized"
|
|
130
|
-
});
|
|
131
|
-
const n = 50, [s, a] = await this.nylasApiRequest.request({
|
|
132
|
-
method: "GET",
|
|
133
|
-
path: `scheduling/configurations?limit=${n}${t ? `&page_token=${t}` : ""}`
|
|
134
|
-
});
|
|
135
|
-
return a ? dataResponse(null, {
|
|
136
|
-
message: "Error fetching configurations: " + a.message
|
|
137
|
-
}) : Xr(s) ? dataResponse(null, {
|
|
138
|
-
message: "Error fetching configurations: " + ((l = s.error) == null ? void 0 : l.message)
|
|
139
|
-
}) : (this.nylasSchedulerConfigStore.state.configurations = s.data, this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor = s.next_cursor || null, dataResponse(s.data));
|
|
140
|
-
}
|
|
141
|
-
async getMasterEventById(t) {
|
|
142
|
-
var u, f;
|
|
143
|
-
if (!this.nylasApiRequest)
|
|
144
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
145
|
-
message: "Error fetching master event: Nylas API Request is not initialized"
|
|
146
|
-
});
|
|
147
|
-
const n = this.nylasSchedulerConfigStore.state.selectedGroupEvent, s = (u = n == null ? void 0 : n.event) == null ? void 0 : u.calendar_id;
|
|
148
|
-
if (!s)
|
|
149
|
-
return console.warn("Calendar ID is not present"), dataResponse(null, {
|
|
150
|
-
message: "Error fetching master event: Calendar ID is not present"
|
|
151
|
-
});
|
|
152
|
-
const a = new URLSearchParams();
|
|
153
|
-
a.append("calendar_id", s);
|
|
154
|
-
const [l, d] = await this.nylasApiRequest.request({
|
|
155
|
-
method: "GET",
|
|
156
|
-
path: `events/${t}?${a.toString()}`
|
|
157
|
-
});
|
|
158
|
-
if (d)
|
|
159
|
-
return dataResponse(null, {
|
|
160
|
-
message: "Error fetching master event: " + d.message
|
|
161
|
-
});
|
|
162
|
-
if (Xr(l))
|
|
163
|
-
return dataResponse(null, {
|
|
164
|
-
message: "Error fetching master event: " + ((f = l.error) == null ? void 0 : f.message)
|
|
165
|
-
});
|
|
166
|
-
const c = this.nylasSchedulerConfigStore.state.masterGroupEvents;
|
|
167
|
-
return c[t] ? this.nylasSchedulerConfigStore.state.masterGroupEvents[t] = l.data : this.nylasSchedulerConfigStore.state.masterGroupEvents = { ...c, [t]: l.data }, dataResponse(l.data);
|
|
168
|
-
}
|
|
169
|
-
async createConfiguration(t) {
|
|
170
|
-
var a;
|
|
171
|
-
if (!this.nylasApiRequest)
|
|
172
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
173
|
-
message: "Error creating configuration: Nylas API Request is not initialized"
|
|
174
|
-
});
|
|
175
|
-
const [n, s] = await this.nylasApiRequest.request({
|
|
176
|
-
method: "POST",
|
|
177
|
-
path: "scheduling/configurations",
|
|
178
|
-
body: t
|
|
179
|
-
});
|
|
180
|
-
return s ? dataResponse(null, {
|
|
181
|
-
message: "Error creating configuration: " + s.message
|
|
182
|
-
}) : Xr(n) ? dataResponse(null, {
|
|
183
|
-
message: "Error creating configuration: " + ((a = n.error) == null ? void 0 : a.message)
|
|
184
|
-
}) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
|
|
185
|
-
}
|
|
186
|
-
async updateConfiguration(t) {
|
|
187
|
-
var a;
|
|
188
|
-
if (!this.nylasApiRequest)
|
|
189
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
190
|
-
message: "Error updating configuration: Nylas API Request is not initialized"
|
|
191
|
-
});
|
|
192
|
-
const [n, s] = await this.nylasApiRequest.request({
|
|
193
|
-
method: "PUT",
|
|
194
|
-
path: `scheduling/configurations/${t.id}`,
|
|
195
|
-
body: t
|
|
196
|
-
});
|
|
197
|
-
return s ? dataResponse(null, {
|
|
198
|
-
message: "Error updating configuration: " + s.message
|
|
199
|
-
}) : Xr(n) ? dataResponse(null, {
|
|
200
|
-
message: "Error updating configuration: " + ((a = n.error) == null ? void 0 : a.message)
|
|
201
|
-
}) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations.find((l) => l.id === t.id) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((l) => l.id === t.id ? n.data : l) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
|
|
202
|
-
}
|
|
203
|
-
async deleteConfiguration(t) {
|
|
204
|
-
var a, l;
|
|
205
|
-
if (!this.nylasApiRequest)
|
|
206
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
207
|
-
message: "Error deleting configuration: Nylas API Request is not initialized"
|
|
208
|
-
});
|
|
209
|
-
const [n, s] = await this.nylasApiRequest.request({
|
|
210
|
-
method: "DELETE",
|
|
211
|
-
path: `scheduling/configurations/${t}`
|
|
212
|
-
});
|
|
213
|
-
return s ? dataResponse(null, {
|
|
214
|
-
message: "Error deleting configuration: " + s.message
|
|
215
|
-
}) : Xr(n) ? dataResponse(null, {
|
|
216
|
-
message: "Error deleting configuration: " + ((a = n.error) == null ? void 0 : a.message)
|
|
217
|
-
}) : (this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.filter((d) => d.id !== t), ((l = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : l.id) === t && this.nylasSchedulerConfigStore.resetSelectedConfiguration(), dataResponse(n.data));
|
|
218
|
-
}
|
|
219
|
-
async createGroupEvent(t, n) {
|
|
220
|
-
var l;
|
|
221
|
-
if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
|
|
222
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
223
|
-
message: "Error creating group event: Nylas API Request is not initialized"
|
|
224
|
-
});
|
|
225
|
-
const [s, a] = await this.nylasApiRequest.request({
|
|
226
|
-
method: "POST",
|
|
227
|
-
path: `scheduling/configurations/${n}/group-events`,
|
|
228
|
-
body: t
|
|
229
|
-
});
|
|
230
|
-
return a ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
231
|
-
message: "Error creating group event: " + a.message
|
|
232
|
-
})) : Xr(s) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
233
|
-
message: "Error creating group event: " + ((l = s.error) == null ? void 0 : l.message)
|
|
234
|
-
})) : (this.nylasSchedulerConfigStore.state.selectedGroupEvent = s.data, await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(s.data));
|
|
235
|
-
}
|
|
236
|
-
async getGroupEvents(t, n) {
|
|
237
|
-
var m, y;
|
|
238
|
-
if (!this.nylasApiRequest)
|
|
239
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
240
|
-
message: "Error fetching group events: Nylas API Request is not initialized"
|
|
241
|
-
});
|
|
242
|
-
const s = new URLSearchParams();
|
|
243
|
-
s.append("show_all", "true");
|
|
244
|
-
const a = this.nylasSchedulerConfigStore.state.calendarViewDateRange;
|
|
245
|
-
let l, d;
|
|
246
|
-
if (a)
|
|
247
|
-
l = a.start_time, d = a.end_time;
|
|
248
|
-
else {
|
|
249
|
-
const w = getCalendarRange((/* @__PURE__ */ new Date()).toISOString(), "week");
|
|
250
|
-
l = w.startTime.toString(), d = w.endTime.toString();
|
|
251
|
-
}
|
|
252
|
-
const c = `${t}-${l}-${d}`, u = this.groupEventsCache.get(c);
|
|
253
|
-
if (u && Date.now() - u.timestamp < this.CACHE_DURATION)
|
|
254
|
-
return this.nylasSchedulerConfigStore.state.groupEvents = u.data, dataResponse(u.data);
|
|
255
|
-
s.append("start_time", l), s.append("end_time", d);
|
|
256
|
-
const f = (m = n == null ? void 0 : n.group_booking) == null ? void 0 : m.calendar_id;
|
|
257
|
-
f && s.append("calendar_id", f);
|
|
258
|
-
const [g, p] = await this.nylasApiRequest.request({
|
|
259
|
-
method: "GET",
|
|
260
|
-
path: `scheduling/configurations/${t}/group-events?${s.toString()}`
|
|
261
|
-
});
|
|
262
|
-
return p ? dataResponse(null, {
|
|
263
|
-
message: "Error fetching group events: " + p.message
|
|
264
|
-
}) : Xr(g) ? dataResponse(null, {
|
|
265
|
-
message: "Error fetching group events: " + ((y = g.error) == null ? void 0 : y.message)
|
|
266
|
-
}) : (this.groupEventsCache.set(c, {
|
|
267
|
-
data: g.data,
|
|
268
|
-
timestamp: Date.now()
|
|
269
|
-
}), this.cleanupExpiredCache(), this.nylasSchedulerConfigStore.state.groupEvents = g.data, dataResponse(g.data));
|
|
270
|
-
}
|
|
271
|
-
cleanupExpiredCache() {
|
|
272
|
-
const t = Date.now();
|
|
273
|
-
for (const [n, s] of this.groupEventsCache.entries())
|
|
274
|
-
t - s.timestamp > this.CACHE_DURATION && this.groupEventsCache.delete(n);
|
|
275
|
-
}
|
|
276
|
-
async updateGroupEventById(t, n) {
|
|
277
|
-
var d;
|
|
278
|
-
if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
|
|
279
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
280
|
-
message: "Error updating group event: Nylas API Request is not initialized"
|
|
281
|
-
});
|
|
282
|
-
const s = t.id;
|
|
283
|
-
delete t.id;
|
|
284
|
-
const [a, l] = await this.nylasApiRequest.request({
|
|
285
|
-
method: "PATCH",
|
|
286
|
-
path: `scheduling/configurations/${n}/group-events/${s}`,
|
|
287
|
-
body: t
|
|
288
|
-
});
|
|
289
|
-
return l ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
290
|
-
message: "Error updating group event: " + l.message
|
|
291
|
-
})) : Xr(a) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
292
|
-
message: "Error updating group event: " + ((d = a.error) == null ? void 0 : d.message)
|
|
293
|
-
})) : (this.nylasSchedulerConfigStore.state.selectedGroupEvent = a.data, await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(a.data));
|
|
294
|
-
}
|
|
295
|
-
async updateGroupEvent(t, n, s) {
|
|
296
|
-
var p, m, y, w, v, x, R, A, I, U, N, O, k, T;
|
|
297
|
-
this.nylasSchedulerConfigStore.state.isLoading = !0;
|
|
298
|
-
const a = this.nylasSchedulerConfigStore.state.selectedGroupEvent, l = (p = a == null ? void 0 : a.event) == null ? void 0 : p.master_event_id, d = (m = a == null ? void 0 : a.event) == null ? void 0 : m.id, c = (w = (y = a == null ? void 0 : a.event) == null ? void 0 : y.when) == null ? void 0 : w.start_time, u = (x = (v = a == null ? void 0 : a.group_event_info) == null ? void 0 : v.rrule) == null ? void 0 : x[0], f = u ? u.split(";").filter((S) => !S.startsWith("UNTIL")).join(";") : "", g = c ? dayjs(c * 1e3).subtract(1, "minute").format("YYYYMMDDTHHmmss[Z]") : "";
|
|
299
|
-
if (n === "this")
|
|
300
|
-
return this.updateGroupEventById({
|
|
301
|
-
...t,
|
|
302
|
-
id: d,
|
|
303
|
-
recurrence: l ? void 0 : t.recurrence
|
|
304
|
-
}, s);
|
|
305
|
-
if (n === "future" && l) {
|
|
306
|
-
const S = await this.createGroupEvent(t, s), _ = {
|
|
307
|
-
location: (R = a == null ? void 0 : a.event) == null ? void 0 : R.location,
|
|
308
|
-
conferencing: (A = a == null ? void 0 : a.event) == null ? void 0 : A.conferencing,
|
|
309
|
-
title: (I = a == null ? void 0 : a.event) == null ? void 0 : I.title,
|
|
310
|
-
description: (U = a == null ? void 0 : a.event) == null ? void 0 : U.description,
|
|
311
|
-
capacity: (N = a == null ? void 0 : a.group_event_info) == null ? void 0 : N.capacity,
|
|
312
|
-
calendar_id: (O = a == null ? void 0 : a.event) == null ? void 0 : O.calendar_id,
|
|
313
|
-
recurrence: f ? [f + ";UNTIL=" + g] : [`RRULE:FREQ=DAILY;UNTIL=${g}`]
|
|
314
|
-
};
|
|
315
|
-
return await this.updateGroupEventById({
|
|
316
|
-
..._,
|
|
317
|
-
id: l
|
|
318
|
-
}, s), [_, S];
|
|
319
|
-
} else if (n === "all") {
|
|
320
|
-
const S = t == null ? void 0 : t.when, _ = (k = a == null ? void 0 : a.event) == null ? void 0 : k.when, L = (T = this.nylasSchedulerConfigStore.state.masterGroupEvents) == null ? void 0 : T[l];
|
|
321
|
-
let b = L == null ? void 0 : L.when;
|
|
322
|
-
return (S == null ? void 0 : S.start_time) !== (_ == null ? void 0 : _.start_time) && (b = {
|
|
323
|
-
...b,
|
|
324
|
-
start_time: (S == null ? void 0 : S.start_time) || (b == null ? void 0 : b.start_time)
|
|
325
|
-
}), (S == null ? void 0 : S.end_time) !== (_ == null ? void 0 : _.end_time) && (b = {
|
|
326
|
-
...b,
|
|
327
|
-
end_time: (S == null ? void 0 : S.end_time) || (b == null ? void 0 : b.end_time)
|
|
328
|
-
}), (S == null ? void 0 : S.start_timezone) !== (_ == null ? void 0 : _.start_timezone) && (b = {
|
|
329
|
-
...b,
|
|
330
|
-
start_timezone: (S == null ? void 0 : S.start_timezone) || (b == null ? void 0 : b.start_timezone)
|
|
331
|
-
}), (S == null ? void 0 : S.end_timezone) !== (_ == null ? void 0 : _.end_timezone) && (b = {
|
|
332
|
-
...b,
|
|
333
|
-
end_timezone: (S == null ? void 0 : S.end_timezone) || (b == null ? void 0 : b.end_timezone)
|
|
334
|
-
}), this.updateGroupEventById({
|
|
335
|
-
...t,
|
|
336
|
-
when: b,
|
|
337
|
-
id: l
|
|
338
|
-
}, s);
|
|
339
|
-
}
|
|
340
|
-
throw this.nylasSchedulerConfigStore.state.isLoading = !1, new Error("Invalid option");
|
|
341
|
-
}
|
|
342
|
-
async deleteGroupEvent(t, n, s) {
|
|
343
|
-
var m, y, w, v, x, R, A, I, U, N, O, k;
|
|
344
|
-
this.nylasSchedulerConfigStore.state.isLoading = !0;
|
|
345
|
-
const a = this.nylasSchedulerConfigStore.state.selectedGroupEvent, l = (m = a == null ? void 0 : a.event) == null ? void 0 : m.master_event_id, d = (y = a == null ? void 0 : a.event) == null ? void 0 : y.id, c = (v = (w = a == null ? void 0 : a.event) == null ? void 0 : w.when) == null ? void 0 : v.start_time, u = (R = (x = a == null ? void 0 : a.group_event_info) == null ? void 0 : x.rrule) == null ? void 0 : R[0], f = u ? u.split(";").filter((T) => !T.startsWith("UNTIL")).join(";") : "", g = c ? dayjs(c * 1e3).format("YYYYMMDDTHHmmss[Z]") : "", p = {
|
|
346
|
-
location: (A = a == null ? void 0 : a.event) == null ? void 0 : A.location,
|
|
347
|
-
conferencing: (I = a == null ? void 0 : a.event) == null ? void 0 : I.conferencing,
|
|
348
|
-
title: (U = a == null ? void 0 : a.event) == null ? void 0 : U.title,
|
|
349
|
-
description: (N = a == null ? void 0 : a.event) == null ? void 0 : N.description,
|
|
350
|
-
capacity: (O = a == null ? void 0 : a.group_event_info) == null ? void 0 : O.capacity,
|
|
351
|
-
calendar_id: (k = a == null ? void 0 : a.event) == null ? void 0 : k.calendar_id,
|
|
352
|
-
recurrence: f ? [f + ";UNTIL=" + g] : [`RRULE:UNTIL=${g}`]
|
|
353
|
-
};
|
|
354
|
-
if (n === "this" && d)
|
|
355
|
-
return this.deleteGroupEventById(d, s);
|
|
356
|
-
if (n === "future" && l && d)
|
|
357
|
-
return await this.deleteGroupEventById(d, s), await this.updateGroupEventById({
|
|
358
|
-
...p,
|
|
359
|
-
id: l
|
|
360
|
-
}, s);
|
|
361
|
-
if (n === "all" && l)
|
|
362
|
-
return this.deleteGroupEventById(l, s);
|
|
363
|
-
throw this.nylasSchedulerConfigStore.state.isLoading = !1, new Error("Invalid option");
|
|
364
|
-
}
|
|
365
|
-
async deleteGroupEventById(t, n) {
|
|
366
|
-
var c, u, f;
|
|
367
|
-
if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
|
|
368
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
369
|
-
message: "Error deleting group event: Nylas API Request is not initialized"
|
|
370
|
-
});
|
|
371
|
-
const s = new URLSearchParams(), a = (u = (c = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : c.group_booking) == null ? void 0 : u.calendar_id;
|
|
372
|
-
a && s.append("calendar_id", a);
|
|
373
|
-
const [l, d] = await this.nylasApiRequest.request({
|
|
374
|
-
method: "DELETE",
|
|
375
|
-
path: `scheduling/configurations/${n}/group-events/${t}?calendar_id=${a}`
|
|
376
|
-
});
|
|
377
|
-
return d ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
378
|
-
message: "Error deleting group event: " + d.message
|
|
379
|
-
})) : Xr(l) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
380
|
-
message: "Error deleting group event: " + ((f = l.error) == null ? void 0 : f.message)
|
|
381
|
-
})) : (await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(l.data));
|
|
382
|
-
}
|
|
383
|
-
async importGroupEvent(t, n) {
|
|
384
|
-
var c, u, f, g, p;
|
|
385
|
-
if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
|
|
386
|
-
return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
|
|
387
|
-
message: "Error importing group event: Nylas API Request is not initialized"
|
|
388
|
-
});
|
|
389
|
-
const s = new URLSearchParams(), a = (u = (c = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : c.group_booking) == null ? void 0 : u.calendar_id;
|
|
390
|
-
a && s.append("calendar_id", a);
|
|
391
|
-
const [l, d] = await this.nylasApiRequest.request({
|
|
392
|
-
method: "POST",
|
|
393
|
-
path: `scheduling/configurations/${n}/import-group-events?${s.toString()}`,
|
|
394
|
-
body: t
|
|
395
|
-
});
|
|
396
|
-
return d ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
397
|
-
message: "Error importing group event: " + d.message
|
|
398
|
-
})) : Xr(l) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
|
|
399
|
-
message: "Error importing group event: " + ((f = l.error) == null ? void 0 : f.message)
|
|
400
|
-
})) : (((p = (g = l.data) == null ? void 0 : g.imported_events) == null ? void 0 : p.length) > 0 && await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(l.data));
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
class NylasSchedulerConfigConnector {
|
|
404
|
-
constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
|
|
405
|
-
this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
|
|
406
|
-
}
|
|
407
|
-
init() {
|
|
408
|
-
debug("NylasSchedulerConfigConnector init");
|
|
409
|
-
}
|
|
410
|
-
get schedulerConfigStore() {
|
|
411
|
-
return this.nylasSchedulerConfigStore;
|
|
412
|
-
}
|
|
413
|
-
get schedulerConfig() {
|
|
414
|
-
return this._schedulerConfigConnector ? this._schedulerConfigConnector : (this._schedulerConfigConnector = new NylasSchedulerConfigAPIConnector({
|
|
415
|
-
nylasApiRequest: this.nylasApiRequest,
|
|
416
|
-
nylasSchedulerConfigStore: this.nylasSchedulerConfigStore
|
|
417
|
-
}), this._schedulerConfigConnector);
|
|
418
|
-
}
|
|
419
|
-
resetStores() {
|
|
420
|
-
debug("NylasSchedulerConfigConnector resetStores"), this.nylasSchedulerConfigStore.reset();
|
|
421
|
-
}
|
|
422
|
-
async logout() {
|
|
423
|
-
debug("NylasSchedulerConfigConnector logout"), this.resetStores();
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
function CreateNylasSchedulerConfigStore(r = {}) {
|
|
427
|
-
const t = {
|
|
428
|
-
selectedConfiguration: {},
|
|
429
|
-
configurations: [],
|
|
430
|
-
groupEvents: [],
|
|
431
|
-
listConfigurationsNextCursor: null,
|
|
432
|
-
calendars: [],
|
|
433
|
-
currentUser: null,
|
|
434
|
-
action: null,
|
|
435
|
-
additionalParticipants: [],
|
|
436
|
-
requiresSlug: !1,
|
|
437
|
-
masterGroupEvents: {},
|
|
438
|
-
isLoading: !1,
|
|
439
|
-
...r
|
|
440
|
-
}, n = createStore(t);
|
|
441
|
-
function s() {
|
|
442
|
-
n.set("selectedConfiguration", { ...r.selectedConfiguration });
|
|
443
|
-
}
|
|
444
|
-
return n.onChange("action", async (a) => {
|
|
445
|
-
a || s();
|
|
446
|
-
}), {
|
|
447
|
-
...n,
|
|
448
|
-
resetSelectedConfiguration: s
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
class LocalStorage {
|
|
452
|
-
get(t) {
|
|
453
|
-
return new Promise((n) => {
|
|
454
|
-
const s = window.localStorage.getItem(t);
|
|
455
|
-
n(s ? JSON.parse(s) : null);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
async remove(t) {
|
|
459
|
-
return window.localStorage.removeItem(t), new Promise((n) => {
|
|
460
|
-
n(null);
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
set(t, n) {
|
|
464
|
-
return window.localStorage.setItem(t, JSON.stringify(n)), new Promise((s) => {
|
|
465
|
-
s(null);
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
const PKCE_KEY = "pkce", GRANT_KEY = "grant", USER_KEY = "user";
|
|
470
|
-
class Storage {
|
|
471
|
-
constructor(t) {
|
|
472
|
-
P(this, "Storage", new LocalStorage());
|
|
473
|
-
if (t) {
|
|
474
|
-
this.Storage = t;
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
setPKCE(t) {
|
|
479
|
-
const n = Buffer.from(t);
|
|
480
|
-
this.Storage.set(PKCE_KEY, n.toString("base64"));
|
|
481
|
-
}
|
|
482
|
-
async getPKCE() {
|
|
483
|
-
try {
|
|
484
|
-
const t = await this.Storage.get(PKCE_KEY);
|
|
485
|
-
if (t)
|
|
486
|
-
return Buffer.from(t, "base64").toString("utf8");
|
|
487
|
-
} catch {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
return null;
|
|
491
|
-
}
|
|
492
|
-
removePKCE() {
|
|
493
|
-
this.Storage.remove(PKCE_KEY);
|
|
494
|
-
}
|
|
495
|
-
setGrant(t, n = !1) {
|
|
496
|
-
const { grant_id: s } = t;
|
|
497
|
-
this.Storage.set(`${GRANT_KEY}${n ? "-" + s : ""}`, t);
|
|
498
|
-
}
|
|
499
|
-
removeGrant(t, n = !1) {
|
|
500
|
-
this.Storage.remove(`${GRANT_KEY}${n ? "-" + t : ""}`);
|
|
501
|
-
}
|
|
502
|
-
async getGrant(t, n = !1) {
|
|
503
|
-
const s = await this.Storage.get(`${GRANT_KEY}${n ? "-" + t : ""}`);
|
|
504
|
-
return s || null;
|
|
505
|
-
}
|
|
506
|
-
// setUserToken is used to store the IDToken in storage
|
|
507
|
-
async setUserToken(t) {
|
|
508
|
-
const n = await this.getUserTokens();
|
|
509
|
-
if (n)
|
|
510
|
-
if (n.find((a) => a.sub === t.sub)) {
|
|
511
|
-
const a = n.map((l) => (l.sub === t.sub && (l = t), l));
|
|
512
|
-
this.Storage.set(USER_KEY, a);
|
|
513
|
-
} else {
|
|
514
|
-
const a = [...n, t];
|
|
515
|
-
this.Storage.set(USER_KEY, a);
|
|
516
|
-
}
|
|
517
|
-
else
|
|
518
|
-
this.Storage.set(USER_KEY, [t]);
|
|
519
|
-
}
|
|
520
|
-
// getUserToken is used to retrieve a specific IDToken from storage
|
|
521
|
-
async getUserToken(t = "") {
|
|
522
|
-
const n = await this.Storage.get(USER_KEY);
|
|
523
|
-
return n ? t === "" ? n[0] : n.find((a) => a.sub === t) : null;
|
|
524
|
-
}
|
|
525
|
-
// getUserTokens is used to retrieve all IDTokens from storage
|
|
526
|
-
async getUserTokens() {
|
|
527
|
-
const t = await this.Storage.get(USER_KEY);
|
|
528
|
-
return t || null;
|
|
529
|
-
}
|
|
530
|
-
// removeUserTokens is used to remove all IDTokens from storage
|
|
531
|
-
removeUserTokens() {
|
|
532
|
-
this.Storage.remove(USER_KEY);
|
|
533
|
-
}
|
|
534
|
-
// removeUserToken is used to remove a specific IDToken from storage
|
|
535
|
-
async removeUserToken(t) {
|
|
536
|
-
const n = await this.getUserTokens(), s = n == null ? void 0 : n.filter((a) => a.sub !== t);
|
|
537
|
-
this.Storage.set(USER_KEY, s);
|
|
538
|
-
}
|
|
539
|
-
async clearSession() {
|
|
540
|
-
const t = await this.getUserTokens();
|
|
541
|
-
t == null || t.forEach((n) => {
|
|
542
|
-
this.removeGrant(n.sub);
|
|
543
|
-
}), this.removePKCE(), this.removeUserTokens();
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
class IndexedDBStorage {
|
|
547
|
-
constructor() {
|
|
548
|
-
P(this, "databaseName", "identity-db");
|
|
549
|
-
P(this, "storeName", "identity");
|
|
550
|
-
}
|
|
551
|
-
get(t) {
|
|
552
|
-
const n = this;
|
|
553
|
-
return new Promise((s, a) => {
|
|
554
|
-
n.openDatabase().then(function(l) {
|
|
555
|
-
const d = l.transaction(n.storeName, "readwrite"), u = d.objectStore(n.storeName).get(t);
|
|
556
|
-
u.onsuccess = () => {
|
|
557
|
-
s(u.result);
|
|
558
|
-
}, u.onerror = () => {
|
|
559
|
-
a(u.error);
|
|
560
|
-
}, d.oncomplete = () => {
|
|
561
|
-
l.close();
|
|
562
|
-
};
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
async remove(t) {
|
|
567
|
-
const n = this;
|
|
568
|
-
return new Promise((s, a) => {
|
|
569
|
-
const l = indexedDB.open(this.databaseName);
|
|
570
|
-
l.onupgradeneeded = function(d) {
|
|
571
|
-
d.target.result.createObjectStore(n.storeName);
|
|
572
|
-
}, l.onerror = () => {
|
|
573
|
-
a(l.error);
|
|
574
|
-
}, l.onsuccess = (d) => {
|
|
575
|
-
const c = d.target.result, u = c.transaction(this.storeName, "readwrite"), g = u.objectStore(this.storeName).delete(t);
|
|
576
|
-
g.onsuccess = () => {
|
|
577
|
-
s(null);
|
|
578
|
-
}, g.onerror = () => {
|
|
579
|
-
a(g.error);
|
|
580
|
-
}, u.oncomplete = () => {
|
|
581
|
-
c.close();
|
|
582
|
-
};
|
|
583
|
-
};
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
set(t, n) {
|
|
587
|
-
return new Promise((s, a) => {
|
|
588
|
-
const l = indexedDB.open(this.databaseName);
|
|
589
|
-
l.onerror = () => {
|
|
590
|
-
a(l.error);
|
|
591
|
-
}, l.onupgradeneeded = (d) => {
|
|
592
|
-
d.target.result.createObjectStore(this.storeName);
|
|
593
|
-
}, l.onsuccess = (d) => {
|
|
594
|
-
const c = d.target.result, u = c.transaction(this.storeName, "readwrite"), g = u.objectStore(this.storeName).put(n, t);
|
|
595
|
-
g.onsuccess = () => {
|
|
596
|
-
s(n);
|
|
597
|
-
}, g.onerror = () => {
|
|
598
|
-
a(g.error);
|
|
599
|
-
}, u.oncomplete = () => {
|
|
600
|
-
c.close();
|
|
601
|
-
};
|
|
602
|
-
};
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
openDatabase() {
|
|
606
|
-
const t = this;
|
|
607
|
-
return new Promise(function(n, s) {
|
|
608
|
-
const a = indexedDB.open(t.databaseName, 2);
|
|
609
|
-
a.onupgradeneeded = function(l) {
|
|
610
|
-
l.target.result.createObjectStore(t.storeName);
|
|
611
|
-
}, a.onsuccess = function(l) {
|
|
612
|
-
n(l.target.result);
|
|
613
|
-
}, a.onerror = function(l) {
|
|
614
|
-
s(l.error);
|
|
615
|
-
};
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
var sha256 = { exports: {} };
|
|
620
|
-
(function(module) {
|
|
621
|
-
(function() {
|
|
622
|
-
var ERROR = "input is invalid type", WINDOW = typeof window == "object", root = WINDOW ? window : {};
|
|
623
|
-
root.JS_SHA256_NO_WINDOW && (WINDOW = !1);
|
|
624
|
-
var WEB_WORKER = !WINDOW && typeof self == "object", NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
|
|
625
|
-
NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
|
|
626
|
-
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 = [
|
|
627
|
-
1116352408,
|
|
628
|
-
1899447441,
|
|
629
|
-
3049323471,
|
|
630
|
-
3921009573,
|
|
631
|
-
961987163,
|
|
632
|
-
1508970993,
|
|
633
|
-
2453635748,
|
|
634
|
-
2870763221,
|
|
635
|
-
3624381080,
|
|
636
|
-
310598401,
|
|
637
|
-
607225278,
|
|
638
|
-
1426881987,
|
|
639
|
-
1925078388,
|
|
640
|
-
2162078206,
|
|
641
|
-
2614888103,
|
|
642
|
-
3248222580,
|
|
643
|
-
3835390401,
|
|
644
|
-
4022224774,
|
|
645
|
-
264347078,
|
|
646
|
-
604807628,
|
|
647
|
-
770255983,
|
|
648
|
-
1249150122,
|
|
649
|
-
1555081692,
|
|
650
|
-
1996064986,
|
|
651
|
-
2554220882,
|
|
652
|
-
2821834349,
|
|
653
|
-
2952996808,
|
|
654
|
-
3210313671,
|
|
655
|
-
3336571891,
|
|
656
|
-
3584528711,
|
|
657
|
-
113926993,
|
|
658
|
-
338241895,
|
|
659
|
-
666307205,
|
|
660
|
-
773529912,
|
|
661
|
-
1294757372,
|
|
662
|
-
1396182291,
|
|
663
|
-
1695183700,
|
|
664
|
-
1986661051,
|
|
665
|
-
2177026350,
|
|
666
|
-
2456956037,
|
|
667
|
-
2730485921,
|
|
668
|
-
2820302411,
|
|
669
|
-
3259730800,
|
|
670
|
-
3345764771,
|
|
671
|
-
3516065817,
|
|
672
|
-
3600352804,
|
|
673
|
-
4094571909,
|
|
674
|
-
275423344,
|
|
675
|
-
430227734,
|
|
676
|
-
506948616,
|
|
677
|
-
659060556,
|
|
678
|
-
883997877,
|
|
679
|
-
958139571,
|
|
680
|
-
1322822218,
|
|
681
|
-
1537002063,
|
|
682
|
-
1747873779,
|
|
683
|
-
1955562222,
|
|
684
|
-
2024104815,
|
|
685
|
-
2227730452,
|
|
686
|
-
2361852424,
|
|
687
|
-
2428436474,
|
|
688
|
-
2756734187,
|
|
689
|
-
3204031479,
|
|
690
|
-
3329325298
|
|
691
|
-
], OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"], blocks = [];
|
|
692
|
-
(root.JS_SHA256_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(r) {
|
|
693
|
-
return Object.prototype.toString.call(r) === "[object Array]";
|
|
694
|
-
}), ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(r) {
|
|
695
|
-
return typeof r == "object" && r.buffer && r.buffer.constructor === ArrayBuffer;
|
|
696
|
-
});
|
|
697
|
-
var createOutputMethod = function(r, t) {
|
|
698
|
-
return function(n) {
|
|
699
|
-
return new Sha256(t, !0).update(n)[r]();
|
|
700
|
-
};
|
|
701
|
-
}, createMethod = function(r) {
|
|
702
|
-
var t = createOutputMethod("hex", r);
|
|
703
|
-
NODE_JS && (t = nodeWrap(t, r)), t.create = function() {
|
|
704
|
-
return new Sha256(r);
|
|
705
|
-
}, t.update = function(a) {
|
|
706
|
-
return t.create().update(a);
|
|
707
|
-
};
|
|
708
|
-
for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
|
|
709
|
-
var s = OUTPUT_TYPES[n];
|
|
710
|
-
t[s] = createOutputMethod(s, r);
|
|
711
|
-
}
|
|
712
|
-
return t;
|
|
713
|
-
}, nodeWrap = function(method, is224) {
|
|
714
|
-
var crypto = eval("require('crypto')"), Buffer = eval("require('buffer').Buffer"), algorithm = is224 ? "sha224" : "sha256", nodeMethod = function(r) {
|
|
715
|
-
if (typeof r == "string")
|
|
716
|
-
return crypto.createHash(algorithm).update(r, "utf8").digest("hex");
|
|
717
|
-
if (r == null)
|
|
718
|
-
throw new Error(ERROR);
|
|
719
|
-
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);
|
|
720
|
-
};
|
|
721
|
-
return nodeMethod;
|
|
722
|
-
}, createHmacOutputMethod = function(r, t) {
|
|
723
|
-
return function(n, s) {
|
|
724
|
-
return new HmacSha256(n, t, !0).update(s)[r]();
|
|
725
|
-
};
|
|
726
|
-
}, createHmacMethod = function(r) {
|
|
727
|
-
var t = createHmacOutputMethod("hex", r);
|
|
728
|
-
t.create = function(a) {
|
|
729
|
-
return new HmacSha256(a, r);
|
|
730
|
-
}, t.update = function(a, l) {
|
|
731
|
-
return t.create(a).update(l);
|
|
732
|
-
};
|
|
733
|
-
for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
|
|
734
|
-
var s = OUTPUT_TYPES[n];
|
|
735
|
-
t[s] = createHmacOutputMethod(s, r);
|
|
736
|
-
}
|
|
737
|
-
return t;
|
|
738
|
-
};
|
|
739
|
-
function Sha256(r, t) {
|
|
740
|
-
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;
|
|
741
|
-
}
|
|
742
|
-
Sha256.prototype.update = function(r) {
|
|
743
|
-
if (!this.finalized) {
|
|
744
|
-
var t, n = typeof r;
|
|
745
|
-
if (n !== "string") {
|
|
746
|
-
if (n === "object") {
|
|
747
|
-
if (r === null)
|
|
748
|
-
throw new Error(ERROR);
|
|
749
|
-
if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
|
|
750
|
-
r = new Uint8Array(r);
|
|
751
|
-
else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
|
|
752
|
-
throw new Error(ERROR);
|
|
753
|
-
} else
|
|
754
|
-
throw new Error(ERROR);
|
|
755
|
-
t = !0;
|
|
756
|
-
}
|
|
757
|
-
for (var s, a = 0, l, d = r.length, c = this.blocks; a < d; ) {
|
|
758
|
-
if (this.hashed && (this.hashed = !1, c[0] = this.block, c[16] = c[1] = c[2] = c[3] = c[4] = c[5] = c[6] = c[7] = c[8] = c[9] = c[10] = c[11] = c[12] = c[13] = c[14] = c[15] = 0), t)
|
|
759
|
-
for (l = this.start; a < d && l < 64; ++a)
|
|
760
|
-
c[l >> 2] |= r[a] << SHIFT[l++ & 3];
|
|
761
|
-
else
|
|
762
|
-
for (l = this.start; a < d && l < 64; ++a)
|
|
763
|
-
s = r.charCodeAt(a), s < 128 ? c[l >> 2] |= s << SHIFT[l++ & 3] : s < 2048 ? (c[l >> 2] |= (192 | s >> 6) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]) : s < 55296 || s >= 57344 ? (c[l >> 2] |= (224 | s >> 12) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 6 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]) : (s = 65536 + ((s & 1023) << 10 | r.charCodeAt(++a) & 1023), c[l >> 2] |= (240 | s >> 18) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 12 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 6 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]);
|
|
764
|
-
this.lastByteIndex = l, this.bytes += l - this.start, l >= 64 ? (this.block = c[16], this.start = l - 64, this.hash(), this.hashed = !0) : this.start = l;
|
|
765
|
-
}
|
|
766
|
-
return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296), this;
|
|
767
|
-
}
|
|
768
|
-
}, Sha256.prototype.finalize = function() {
|
|
769
|
-
if (!this.finalized) {
|
|
770
|
-
this.finalized = !0;
|
|
771
|
-
var r = this.blocks, t = this.lastByteIndex;
|
|
772
|
-
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();
|
|
773
|
-
}
|
|
774
|
-
}, Sha256.prototype.hash = function() {
|
|
775
|
-
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = this.h7, u = this.blocks, f, g, p, m, y, w, v, x, R, A, I;
|
|
776
|
-
for (f = 16; f < 64; ++f)
|
|
777
|
-
y = u[f - 15], g = (y >>> 7 | y << 25) ^ (y >>> 18 | y << 14) ^ y >>> 3, y = u[f - 2], p = (y >>> 17 | y << 15) ^ (y >>> 19 | y << 13) ^ y >>> 10, u[f] = u[f - 16] + g + u[f - 7] + p << 0;
|
|
778
|
-
for (I = t & n, f = 0; f < 64; f += 4)
|
|
779
|
-
this.first ? (this.is224 ? (x = 300032, y = u[0] - 1413257819, c = y - 150054599 << 0, s = y + 24177077 << 0) : (x = 704751109, y = u[0] - 210244248, c = y - 1521486534 << 0, s = y + 143694565 << 0), this.first = !1) : (g = (r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10), p = (a >>> 6 | a << 26) ^ (a >>> 11 | a << 21) ^ (a >>> 25 | a << 7), x = r & t, m = x ^ r & n ^ I, v = a & l ^ ~a & d, y = c + p + v + K[f] + u[f], w = g + m, c = s + y << 0, s = y + w << 0), g = (s >>> 2 | s << 30) ^ (s >>> 13 | s << 19) ^ (s >>> 22 | s << 10), p = (c >>> 6 | c << 26) ^ (c >>> 11 | c << 21) ^ (c >>> 25 | c << 7), R = s & r, m = R ^ s & t ^ x, v = c & a ^ ~c & l, y = d + p + v + K[f + 1] + u[f + 1], w = g + m, d = n + y << 0, n = y + w << 0, g = (n >>> 2 | n << 30) ^ (n >>> 13 | n << 19) ^ (n >>> 22 | n << 10), p = (d >>> 6 | d << 26) ^ (d >>> 11 | d << 21) ^ (d >>> 25 | d << 7), A = n & s, m = A ^ n & r ^ R, v = d & c ^ ~d & a, y = l + p + v + K[f + 2] + u[f + 2], w = g + m, l = t + y << 0, t = y + w << 0, g = (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10), p = (l >>> 6 | l << 26) ^ (l >>> 11 | l << 21) ^ (l >>> 25 | l << 7), I = t & n, m = I ^ t & s ^ A, v = l & d ^ ~l & c, y = a + p + v + K[f + 3] + u[f + 3], w = g + m, a = r + y << 0, r = y + w << 0;
|
|
780
|
-
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 + a << 0, this.h5 = this.h5 + l << 0, this.h6 = this.h6 + d << 0, this.h7 = this.h7 + c << 0;
|
|
781
|
-
}, Sha256.prototype.hex = function() {
|
|
782
|
-
this.finalize();
|
|
783
|
-
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = 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[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[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] + 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];
|
|
784
|
-
return this.is224 || (u += 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]), u;
|
|
785
|
-
}, Sha256.prototype.toString = Sha256.prototype.hex, Sha256.prototype.digest = function() {
|
|
786
|
-
this.finalize();
|
|
787
|
-
var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = this.h7, u = [
|
|
788
|
-
r >> 24 & 255,
|
|
789
|
-
r >> 16 & 255,
|
|
790
|
-
r >> 8 & 255,
|
|
791
|
-
r & 255,
|
|
792
|
-
t >> 24 & 255,
|
|
793
|
-
t >> 16 & 255,
|
|
794
|
-
t >> 8 & 255,
|
|
795
|
-
t & 255,
|
|
796
|
-
n >> 24 & 255,
|
|
797
|
-
n >> 16 & 255,
|
|
798
|
-
n >> 8 & 255,
|
|
799
|
-
n & 255,
|
|
800
|
-
s >> 24 & 255,
|
|
801
|
-
s >> 16 & 255,
|
|
802
|
-
s >> 8 & 255,
|
|
803
|
-
s & 255,
|
|
804
|
-
a >> 24 & 255,
|
|
805
|
-
a >> 16 & 255,
|
|
806
|
-
a >> 8 & 255,
|
|
807
|
-
a & 255,
|
|
808
|
-
l >> 24 & 255,
|
|
809
|
-
l >> 16 & 255,
|
|
810
|
-
l >> 8 & 255,
|
|
811
|
-
l & 255,
|
|
812
|
-
d >> 24 & 255,
|
|
813
|
-
d >> 16 & 255,
|
|
814
|
-
d >> 8 & 255,
|
|
815
|
-
d & 255
|
|
816
|
-
];
|
|
817
|
-
return this.is224 || u.push(c >> 24 & 255, c >> 16 & 255, c >> 8 & 255, c & 255), u;
|
|
818
|
-
}, Sha256.prototype.array = Sha256.prototype.digest, Sha256.prototype.arrayBuffer = function() {
|
|
819
|
-
this.finalize();
|
|
820
|
-
var r = new ArrayBuffer(this.is224 ? 28 : 32), t = new DataView(r);
|
|
821
|
-
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;
|
|
822
|
-
};
|
|
823
|
-
function HmacSha256(r, t, n) {
|
|
824
|
-
var s, a = typeof r;
|
|
825
|
-
if (a === "string") {
|
|
826
|
-
var l = [], d = r.length, c = 0, u;
|
|
827
|
-
for (s = 0; s < d; ++s)
|
|
828
|
-
u = r.charCodeAt(s), u < 128 ? l[c++] = u : u < 2048 ? (l[c++] = 192 | u >> 6, l[c++] = 128 | u & 63) : u < 55296 || u >= 57344 ? (l[c++] = 224 | u >> 12, l[c++] = 128 | u >> 6 & 63, l[c++] = 128 | u & 63) : (u = 65536 + ((u & 1023) << 10 | r.charCodeAt(++s) & 1023), l[c++] = 240 | u >> 18, l[c++] = 128 | u >> 12 & 63, l[c++] = 128 | u >> 6 & 63, l[c++] = 128 | u & 63);
|
|
829
|
-
r = l;
|
|
830
|
-
} else if (a === "object") {
|
|
831
|
-
if (r === null)
|
|
832
|
-
throw new Error(ERROR);
|
|
833
|
-
if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
|
|
834
|
-
r = new Uint8Array(r);
|
|
835
|
-
else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
|
|
836
|
-
throw new Error(ERROR);
|
|
837
|
-
} else
|
|
838
|
-
throw new Error(ERROR);
|
|
839
|
-
r.length > 64 && (r = new Sha256(t, !0).update(r).array());
|
|
840
|
-
var f = [], g = [];
|
|
841
|
-
for (s = 0; s < 64; ++s) {
|
|
842
|
-
var p = r[s] || 0;
|
|
843
|
-
f[s] = 92 ^ p, g[s] = 54 ^ p;
|
|
844
|
-
}
|
|
845
|
-
Sha256.call(this, t, n), this.update(g), this.oKeyPad = f, this.inner = !0, this.sharedMemory = n;
|
|
846
|
-
}
|
|
847
|
-
HmacSha256.prototype = new Sha256(), HmacSha256.prototype.finalize = function() {
|
|
848
|
-
if (Sha256.prototype.finalize.call(this), this.inner) {
|
|
849
|
-
this.inner = !1;
|
|
850
|
-
var r = this.array();
|
|
851
|
-
Sha256.call(this, this.is224, this.sharedMemory), this.update(this.oKeyPad), this.update(r), Sha256.prototype.finalize.call(this);
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
var exports = createMethod();
|
|
855
|
-
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);
|
|
856
|
-
})();
|
|
857
|
-
})(sha256);
|
|
858
|
-
var getRandomValues, rnds8 = new Uint8Array(16);
|
|
859
|
-
function rng() {
|
|
860
|
-
if (!getRandomValues && (getRandomValues = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !getRandomValues))
|
|
861
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
862
|
-
return getRandomValues(rnds8);
|
|
863
|
-
}
|
|
864
|
-
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;
|
|
865
|
-
function validate(r) {
|
|
866
|
-
return typeof r == "string" && REGEX.test(r);
|
|
867
|
-
}
|
|
868
|
-
var byteToHex = [];
|
|
869
|
-
for (var i = 0; i < 256; ++i)
|
|
870
|
-
byteToHex.push((i + 256).toString(16).substr(1));
|
|
871
|
-
function stringify(r) {
|
|
872
|
-
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();
|
|
873
|
-
if (!validate(n))
|
|
874
|
-
throw TypeError("Stringified UUID is invalid");
|
|
875
|
-
return n;
|
|
876
|
-
}
|
|
877
|
-
function v4(r, t, n) {
|
|
878
|
-
r = r || {};
|
|
879
|
-
var s = r.random || (r.rng || rng)();
|
|
880
|
-
if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
|
|
881
|
-
n = n || 0;
|
|
882
|
-
for (var a = 0; a < 16; ++a)
|
|
883
|
-
t[n + a] = s[a];
|
|
884
|
-
return t;
|
|
885
|
-
}
|
|
886
|
-
return stringify(s);
|
|
887
|
-
}
|
|
888
|
-
async function getBytes(r, t) {
|
|
889
|
-
const n = r.getReader();
|
|
890
|
-
let s;
|
|
891
|
-
for (; !(s = await n.read()).done; )
|
|
892
|
-
t(s.value);
|
|
893
|
-
}
|
|
894
|
-
function getLines(r) {
|
|
895
|
-
let t, n, s, a = !1;
|
|
896
|
-
return function(d) {
|
|
897
|
-
t === void 0 ? (t = d, n = 0, s = -1) : t = concat(t, d);
|
|
898
|
-
const c = t.length;
|
|
899
|
-
let u = 0;
|
|
900
|
-
for (; n < c; ) {
|
|
901
|
-
a && (t[n] === 10 && (u = ++n), a = !1);
|
|
902
|
-
let f = -1;
|
|
903
|
-
for (; n < c && f === -1; ++n)
|
|
904
|
-
switch (t[n]) {
|
|
905
|
-
case 58:
|
|
906
|
-
s === -1 && (s = n - u);
|
|
907
|
-
break;
|
|
908
|
-
case 13:
|
|
909
|
-
a = !0;
|
|
910
|
-
case 10:
|
|
911
|
-
f = n;
|
|
912
|
-
break;
|
|
913
|
-
}
|
|
914
|
-
if (f === -1)
|
|
915
|
-
break;
|
|
916
|
-
r(t.subarray(u, f), s), u = n, s = -1;
|
|
917
|
-
}
|
|
918
|
-
u === c ? t = void 0 : u !== 0 && (t = t.subarray(u), n -= u);
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
function getMessages(r, t, n) {
|
|
922
|
-
let s = newMessage();
|
|
923
|
-
const a = new TextDecoder();
|
|
924
|
-
return function(d, c) {
|
|
925
|
-
if (d.length === 0)
|
|
926
|
-
n == null || n(s), s = newMessage();
|
|
927
|
-
else if (c > 0) {
|
|
928
|
-
const u = a.decode(d.subarray(0, c)), f = c + (d[c + 1] === 32 ? 2 : 1), g = a.decode(d.subarray(f));
|
|
929
|
-
switch (u) {
|
|
930
|
-
case "data":
|
|
931
|
-
s.data = s.data ? s.data + `
|
|
932
|
-
` + g : g;
|
|
933
|
-
break;
|
|
934
|
-
case "event":
|
|
935
|
-
s.event = g;
|
|
936
|
-
break;
|
|
937
|
-
case "id":
|
|
938
|
-
r(s.id = g);
|
|
939
|
-
break;
|
|
940
|
-
case "retry":
|
|
941
|
-
const p = parseInt(g, 10);
|
|
942
|
-
isNaN(p) || t(s.retry = p);
|
|
943
|
-
break;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
function concat(r, t) {
|
|
949
|
-
const n = new Uint8Array(r.length + t.length);
|
|
950
|
-
return n.set(r), n.set(t, r.length), n;
|
|
951
|
-
}
|
|
952
|
-
function newMessage() {
|
|
953
|
-
return {
|
|
954
|
-
data: "",
|
|
955
|
-
event: "",
|
|
956
|
-
id: "",
|
|
957
|
-
retry: void 0
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
var __rest = function(r, t) {
|
|
961
|
-
var n = {};
|
|
962
|
-
for (var s in r)
|
|
963
|
-
Object.prototype.hasOwnProperty.call(r, s) && t.indexOf(s) < 0 && (n[s] = r[s]);
|
|
964
|
-
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
965
|
-
for (var a = 0, s = Object.getOwnPropertySymbols(r); a < s.length; a++)
|
|
966
|
-
t.indexOf(s[a]) < 0 && Object.prototype.propertyIsEnumerable.call(r, s[a]) && (n[s[a]] = r[s[a]]);
|
|
967
|
-
return n;
|
|
968
|
-
};
|
|
969
|
-
const EventStreamContentType = "text/event-stream", DefaultRetryInterval = 1e3, LastEventId = "last-event-id";
|
|
970
|
-
function fetchEventSource(r, t) {
|
|
971
|
-
var { signal: n, headers: s, onopen: a, onmessage: l, onclose: d, onerror: c, openWhenHidden: u, fetch: f } = t, g = __rest(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
972
|
-
return new Promise((p, m) => {
|
|
973
|
-
const y = Object.assign({}, s);
|
|
974
|
-
y.accept || (y.accept = EventStreamContentType);
|
|
975
|
-
let w;
|
|
976
|
-
function v() {
|
|
977
|
-
w.abort(), document.hidden || N();
|
|
978
|
-
}
|
|
979
|
-
u || document.addEventListener("visibilitychange", v);
|
|
980
|
-
let x = DefaultRetryInterval, R = 0;
|
|
981
|
-
function A() {
|
|
982
|
-
document.removeEventListener("visibilitychange", v), window.clearTimeout(R), w.abort();
|
|
983
|
-
}
|
|
984
|
-
n == null || n.addEventListener("abort", () => {
|
|
985
|
-
A(), p();
|
|
986
|
-
});
|
|
987
|
-
const I = f ?? window.fetch, U = a ?? defaultOnOpen;
|
|
988
|
-
async function N() {
|
|
989
|
-
var O;
|
|
990
|
-
w = new AbortController();
|
|
991
|
-
try {
|
|
992
|
-
const k = await I(r, Object.assign(Object.assign({}, g), { headers: y, signal: w.signal }));
|
|
993
|
-
await U(k), await getBytes(k.body, getLines(getMessages((T) => {
|
|
994
|
-
T ? y[LastEventId] = T : delete y[LastEventId];
|
|
995
|
-
}, (T) => {
|
|
996
|
-
x = T;
|
|
997
|
-
}, l))), d == null || d(), A(), p();
|
|
998
|
-
} catch (k) {
|
|
999
|
-
if (!w.signal.aborted)
|
|
1000
|
-
try {
|
|
1001
|
-
const T = (O = c == null ? void 0 : c(k)) !== null && O !== void 0 ? O : x;
|
|
1002
|
-
window.clearTimeout(R), R = window.setTimeout(N, T);
|
|
1003
|
-
} catch (T) {
|
|
1004
|
-
A(), m(T);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
N();
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
function defaultOnOpen(r) {
|
|
1012
|
-
const t = r.headers.get("content-type");
|
|
1013
|
-
if (!(t != null && t.startsWith(EventStreamContentType)))
|
|
1014
|
-
throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`);
|
|
1015
|
-
}
|
|
1016
|
-
function Base64EncodeUrl(r) {
|
|
1017
|
-
return r.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1018
|
-
}
|
|
1019
|
-
function getTimestamp() {
|
|
1020
|
-
return Math.floor(Date.now() / 1e3);
|
|
1021
|
-
}
|
|
1022
|
-
function e(r) {
|
|
1023
|
-
this.message = r;
|
|
1024
|
-
}
|
|
1025
|
-
e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
|
|
1026
|
-
var r$1 = typeof window < "u" && window.atob && window.atob.bind(window) || function(r) {
|
|
1027
|
-
var t = String(r).replace(/=+$/, "");
|
|
1028
|
-
if (t.length % 4 == 1)
|
|
1029
|
-
throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
1030
|
-
for (var n, s, a = 0, l = 0, d = ""; s = t.charAt(l++); ~s && (n = a % 4 ? 64 * n + s : s, a++ % 4) ? d += String.fromCharCode(255 & n >> (-2 * a & 6)) : 0)
|
|
1031
|
-
s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);
|
|
1032
|
-
return d;
|
|
1033
|
-
};
|
|
1034
|
-
function t$1(r) {
|
|
1035
|
-
var t = r.replace(/-/g, "+").replace(/_/g, "/");
|
|
1036
|
-
switch (t.length % 4) {
|
|
1037
|
-
case 0:
|
|
1038
|
-
break;
|
|
1039
|
-
case 2:
|
|
1040
|
-
t += "==";
|
|
1041
|
-
break;
|
|
1042
|
-
case 3:
|
|
1043
|
-
t += "=";
|
|
1044
|
-
break;
|
|
1045
|
-
default:
|
|
1046
|
-
throw "Illegal base64url string!";
|
|
1047
|
-
}
|
|
1048
|
-
try {
|
|
1049
|
-
return function(n) {
|
|
1050
|
-
return decodeURIComponent(r$1(n).replace(/(.)/g, function(s, a) {
|
|
1051
|
-
var l = a.charCodeAt(0).toString(16).toUpperCase();
|
|
1052
|
-
return l.length < 2 && (l = "0" + l), "%" + l;
|
|
1053
|
-
}));
|
|
1054
|
-
}(t);
|
|
1055
|
-
} catch {
|
|
1056
|
-
return r$1(t);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
function n$1(r) {
|
|
1060
|
-
this.message = r;
|
|
1061
|
-
}
|
|
1062
|
-
function o(r, t) {
|
|
1063
|
-
if (typeof r != "string")
|
|
1064
|
-
throw new n$1("Invalid token specified");
|
|
1065
|
-
var n = (t = t || {}).header === !0 ? 0 : 1;
|
|
1066
|
-
try {
|
|
1067
|
-
return JSON.parse(t$1(r.split(".")[n]));
|
|
1068
|
-
} catch (s) {
|
|
1069
|
-
throw new n$1("Invalid token specified: " + s.message);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
n$1.prototype = new Error(), n$1.prototype.name = "InvalidTokenError";
|
|
1073
|
-
class NylasSessions {
|
|
1074
|
-
constructor(t) {
|
|
1075
|
-
P(this, "clientId");
|
|
1076
|
-
P(this, "redirectUri");
|
|
1077
|
-
P(this, "accessType", "online");
|
|
1078
|
-
P(this, "domain", "http://api.nylas.com");
|
|
1079
|
-
P(this, "versioned", !1);
|
|
1080
|
-
P(this, "Storage");
|
|
1081
|
-
P(this, "hosted", !1);
|
|
1082
|
-
P(this, "multiAccount", !1);
|
|
1083
|
-
P(this, "loginId", "");
|
|
1084
|
-
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) {
|
|
1085
|
-
const n = new IndexedDBStorage();
|
|
1086
|
-
this.Storage = new Storage(n);
|
|
1087
|
-
} else
|
|
1088
|
-
this.Storage = new Storage();
|
|
1089
|
-
t.accessType && (this.accessType = t.accessType), t.loginId && (this.loginId = t.loginId), t.hosted && (this.hosted = t.hosted), t.disableInitCodeExchange !== !0 && this.codeExchange(null);
|
|
1090
|
-
}
|
|
1091
|
-
// Validates access token
|
|
1092
|
-
async validateAccessToken(t = "") {
|
|
1093
|
-
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
1094
|
-
if (!n)
|
|
1095
|
-
return !1;
|
|
1096
|
-
const { access_token: s } = n;
|
|
1097
|
-
try {
|
|
1098
|
-
return !!(await (await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`, {
|
|
1099
|
-
method: "GET"
|
|
1100
|
-
})).json()).data;
|
|
1101
|
-
} catch {
|
|
1102
|
-
return !1;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
// Validates id token
|
|
1106
|
-
async validateIDToken(t = "") {
|
|
1107
|
-
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
1108
|
-
if (!n)
|
|
1109
|
-
return !1;
|
|
1110
|
-
const { id_token: s } = n;
|
|
1111
|
-
try {
|
|
1112
|
-
const a = await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`, {
|
|
1113
|
-
method: "GET"
|
|
1114
|
-
});
|
|
1115
|
-
return !(a.status !== 200 || !(await a.json()).data);
|
|
1116
|
-
} catch {
|
|
1117
|
-
return !1;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
// Gets domain of UAS
|
|
1121
|
-
getDomain() {
|
|
1122
|
-
return this.domain;
|
|
1123
|
-
}
|
|
1124
|
-
// Gets auth link
|
|
1125
|
-
async auth(t) {
|
|
1126
|
-
this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)) && await this.hostedSetCodeChallenge();
|
|
1127
|
-
const n = await this.generateAuthURL(t);
|
|
1128
|
-
if (t.popup) {
|
|
1129
|
-
this.popUp(n);
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
return n;
|
|
1133
|
-
}
|
|
1134
|
-
// Generates auth URL
|
|
1135
|
-
async generateAuthURL(t) {
|
|
1136
|
-
const n = await this.getCodeChallege();
|
|
1137
|
-
let s = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
|
|
1138
|
-
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;
|
|
1139
|
-
}
|
|
1140
|
-
// Generates auth URL
|
|
1141
|
-
async generateReauthURL(t, n) {
|
|
1142
|
-
if (!t)
|
|
1143
|
-
throw new Error("Grant ID is required");
|
|
1144
|
-
const s = await this.Storage.getUserToken(t), a = await this.getCodeChallege();
|
|
1145
|
-
let l = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
|
|
1146
|
-
return a && (l += `&code_challenge=${a}&code_challenge_method=S256&options=rotate_refresh_token`), s != null && s.provider && (l += `&provider=${s.provider}`), s != null && s.email && (l += `&login_hint=${s.email}`), n && (l += `&scope=${n.join(" ")}`), l;
|
|
1147
|
-
}
|
|
1148
|
-
// Generates UUID code challenge
|
|
1149
|
-
async generateCodeChallenge() {
|
|
1150
|
-
if (await this.Storage.getPKCE())
|
|
1151
|
-
return;
|
|
1152
|
-
const n = v4();
|
|
1153
|
-
this.Storage.setPKCE(n);
|
|
1154
|
-
}
|
|
1155
|
-
// Gets code challenge from URL query params
|
|
1156
|
-
async hostedSetCodeChallenge() {
|
|
1157
|
-
if (!this.hosted)
|
|
1158
|
-
throw console.error("Method only used with hosted flag enabled");
|
|
1159
|
-
const n = new URLSearchParams(window.location.search).get("code_challenge");
|
|
1160
|
-
if (!n) {
|
|
1161
|
-
if (await this.Storage.getPKCE())
|
|
1162
|
-
return;
|
|
1163
|
-
console.warn("Code challenge is recomended");
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
this.Storage.setPKCE(n);
|
|
1167
|
-
}
|
|
1168
|
-
// Gets code challenge from store
|
|
1169
|
-
async getCodeChallege() {
|
|
1170
|
-
if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin))) {
|
|
1171
|
-
const s = new URLSearchParams(window.location.search).get("code_challenge");
|
|
1172
|
-
return s || (console.warn("Code challenge is recomended"), "");
|
|
1173
|
-
}
|
|
1174
|
-
const t = await this.Storage.getPKCE();
|
|
1175
|
-
if (t) {
|
|
1176
|
-
const n = sha256.exports.sha256(t);
|
|
1177
|
-
let s = Buffer.from(n).toString("base64");
|
|
1178
|
-
return s = Base64EncodeUrl(s), s;
|
|
1179
|
-
}
|
|
1180
|
-
return "";
|
|
1181
|
-
}
|
|
1182
|
-
// checks if user is logged in
|
|
1183
|
-
async isLoggedIn() {
|
|
1184
|
-
if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)))
|
|
1185
|
-
return !1;
|
|
1186
|
-
const t = await this.Storage.getUserTokens();
|
|
1187
|
-
return t && t.length > 0 ? (this.multiAccount && await this.generateCodeChallenge(), !0) : (await this.generateCodeChallenge(), !1);
|
|
1188
|
-
}
|
|
1189
|
-
// Checks if user is multi account
|
|
1190
|
-
isMultiAccount() {
|
|
1191
|
-
return this.multiAccount;
|
|
1192
|
-
}
|
|
1193
|
-
// Logs user out
|
|
1194
|
-
async logout() {
|
|
1195
|
-
const t = await this.getProfile();
|
|
1196
|
-
await this.Storage.clearSession();
|
|
1197
|
-
const n = { detail: t };
|
|
1198
|
-
window.dispatchEvent(new CustomEvent("onLogoutSuccess", n));
|
|
1199
|
-
}
|
|
1200
|
-
// Gets profile info from ID token
|
|
1201
|
-
async getProfile(t = "") {
|
|
1202
|
-
let n;
|
|
1203
|
-
return t ? n = await this.Storage.getUserToken(t) : n = await this.Storage.getUserToken(), n || null;
|
|
1204
|
-
}
|
|
1205
|
-
// Gets profile info from ID tokens
|
|
1206
|
-
async getProfiles() {
|
|
1207
|
-
const t = await this.Storage.getUserTokens();
|
|
1208
|
-
return t || null;
|
|
1209
|
-
}
|
|
1210
|
-
// Remove a specific profile
|
|
1211
|
-
async removeProfile(t) {
|
|
1212
|
-
return await this.Storage.removeUserToken(t), await this.Storage.removeGrant(t), null;
|
|
1213
|
-
}
|
|
1214
|
-
// IMAP authentication
|
|
1215
|
-
async authIMAP(t) {
|
|
1216
|
-
const n = await this.getCodeChallege(), s = {
|
|
1217
|
-
imap_username: t.imap_username,
|
|
1218
|
-
imap_password: t.imap_password,
|
|
1219
|
-
imap_host: t.imap_host,
|
|
1220
|
-
imap_port: t.imap_port,
|
|
1221
|
-
type: t.type,
|
|
1222
|
-
smtp_host: t.smtp_host,
|
|
1223
|
-
smtp_port: t.smtp_port,
|
|
1224
|
-
provider: t.provider,
|
|
1225
|
-
redirect_uri: this.redirectUri,
|
|
1226
|
-
state: t.state,
|
|
1227
|
-
public_application_id: this.clientId,
|
|
1228
|
-
access_type: this.accessType
|
|
1229
|
-
};
|
|
1230
|
-
return this.loginId && (s.id = this.loginId), t.smtp_username && t.smtp_password && (s.smtp_username = t.smtp_username, s.smtp_password = t.smtp_password), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/imap`, {
|
|
1231
|
-
method: "POST",
|
|
1232
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
1233
|
-
body: JSON.stringify(s)
|
|
1234
|
-
})).json();
|
|
1235
|
-
}
|
|
1236
|
-
// EWS authentication
|
|
1237
|
-
async authEWS(t) {
|
|
1238
|
-
const n = await this.getCodeChallege(), s = {
|
|
1239
|
-
...t,
|
|
1240
|
-
provider: "ews",
|
|
1241
|
-
redirect_uri: this.redirectUri,
|
|
1242
|
-
public_application_id: this.clientId,
|
|
1243
|
-
access_type: this.accessType
|
|
1244
|
-
};
|
|
1245
|
-
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`, {
|
|
1246
|
-
method: "POST",
|
|
1247
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
1248
|
-
body: JSON.stringify(s)
|
|
1249
|
-
})).json();
|
|
1250
|
-
}
|
|
1251
|
-
// Detects email
|
|
1252
|
-
async detectEmail(t) {
|
|
1253
|
-
return await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`, {
|
|
1254
|
-
method: "POST",
|
|
1255
|
-
headers: new Headers({ "content-type": "application/json" })
|
|
1256
|
-
})).json();
|
|
1257
|
-
}
|
|
1258
|
-
// Gets app info from UAS
|
|
1259
|
-
async applicationInfo() {
|
|
1260
|
-
return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/applications?client_id=${this.clientId}`, {
|
|
1261
|
-
method: "GET",
|
|
1262
|
-
headers: new Headers({ "content-type": "application/json" })
|
|
1263
|
-
})).json()).data;
|
|
1264
|
-
}
|
|
1265
|
-
// Gets providers form UAS
|
|
1266
|
-
async getAvailableProviders() {
|
|
1267
|
-
const t = await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`, {
|
|
1268
|
-
method: "GET",
|
|
1269
|
-
headers: new Headers({ "content-type": "application/json" })
|
|
1270
|
-
});
|
|
1271
|
-
return t ? (await t.json()).data : null;
|
|
1272
|
-
}
|
|
1273
|
-
// EVENT HOOKS
|
|
1274
|
-
onLoginSuccess(t) {
|
|
1275
|
-
window.addEventListener("onLoginSuccess", (n) => t(n));
|
|
1276
|
-
}
|
|
1277
|
-
onLogoutSuccess(t) {
|
|
1278
|
-
window.addEventListener("onLogoutSuccess", (n) => t(n));
|
|
1279
|
-
}
|
|
1280
|
-
onLoginFail(t) {
|
|
1281
|
-
window.addEventListener("onLoginFail", (n) => t(n));
|
|
1282
|
-
}
|
|
1283
|
-
onTokenRefreshSuccess(t) {
|
|
1284
|
-
window.addEventListener("onTokenRefreshSuccess", (n) => t(n));
|
|
1285
|
-
}
|
|
1286
|
-
onTokenRefreshFail(t) {
|
|
1287
|
-
window.addEventListener("onTokenRefreshFail", (n) => t(n));
|
|
1288
|
-
}
|
|
1289
|
-
onSessionExpired(t) {
|
|
1290
|
-
window.addEventListener("onSessionExpired", (n) => t(n));
|
|
1291
|
-
}
|
|
1292
|
-
// Exchanges code for ID token and refresh and access tokens
|
|
1293
|
-
async codeExchange(t) {
|
|
1294
|
-
let n = new URLSearchParams(window.location.search);
|
|
1295
|
-
t && (n = new URLSearchParams(t));
|
|
1296
|
-
const s = n.get("code"), a = n.get("state"), l = n.get("error"), d = n.get("error_description"), c = n.get("error_code");
|
|
1297
|
-
if (l && d && c) {
|
|
1298
|
-
const f = {
|
|
1299
|
-
detail: { error: l, error_description: d, error_code: c }
|
|
1300
|
-
};
|
|
1301
|
-
return window.dispatchEvent(new CustomEvent("onLoginFail", f)), window.history.pushState({}, document.title, window.location.pathname), !1;
|
|
1302
|
-
}
|
|
1303
|
-
if (!s)
|
|
1304
|
-
return console.warn("No code found"), !1;
|
|
1305
|
-
if (window.opener && window.name === "uas-popup")
|
|
1306
|
-
return console.warn("Popup window detected"), !1;
|
|
1307
|
-
const u = await this.Storage.getPKCE();
|
|
1308
|
-
if (!u)
|
|
1309
|
-
return console.warn("No code verifier found"), !1;
|
|
1310
|
-
try {
|
|
1311
|
-
const f = {
|
|
1312
|
-
client_id: this.clientId,
|
|
1313
|
-
redirect_uri: this.redirectUri,
|
|
1314
|
-
code: s,
|
|
1315
|
-
grant_type: "authorization_code",
|
|
1316
|
-
code_verifier: u
|
|
1317
|
-
}, p = await (await fetch(`${this.domain}/connect/token`, {
|
|
1318
|
-
method: "POST",
|
|
1319
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
1320
|
-
body: JSON.stringify(f)
|
|
1321
|
-
})).json();
|
|
1322
|
-
if (p) {
|
|
1323
|
-
if (p.error) {
|
|
1324
|
-
const y = { detail: p };
|
|
1325
|
-
return window.dispatchEvent(new CustomEvent("onLoginFail", y)), !0;
|
|
1326
|
-
}
|
|
1327
|
-
const m = await this.handleCodeExchangeResponse(p);
|
|
1328
|
-
if (m.valid) {
|
|
1329
|
-
a && (m.data.state = a);
|
|
1330
|
-
const y = { detail: m.data };
|
|
1331
|
-
window.dispatchEvent(new CustomEvent("onLoginSuccess", y)), window.history.pushState({}, document.title, window.location.pathname);
|
|
1332
|
-
} else {
|
|
1333
|
-
const y = { detail: m.data };
|
|
1334
|
-
return window.dispatchEvent(new CustomEvent("onLoginFail", y)), !0;
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
return this.Storage.removePKCE(), !0;
|
|
1338
|
-
} catch (f) {
|
|
1339
|
-
const g = { detail: f };
|
|
1340
|
-
return window.dispatchEvent(new CustomEvent("onLoginFail", g)), window.history.pushState({}, document.title, window.location.pathname), !1;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
// Token Exchange for session maintenece
|
|
1344
|
-
async tokenExchange(t = "") {
|
|
1345
|
-
const n = await this.Storage.getGrant(t, this.multiAccount);
|
|
1346
|
-
if (!n)
|
|
1347
|
-
return !1;
|
|
1348
|
-
const s = n.refresh_token;
|
|
1349
|
-
try {
|
|
1350
|
-
const a = {
|
|
1351
|
-
client_id: this.clientId,
|
|
1352
|
-
redirect_uri: this.redirectUri,
|
|
1353
|
-
refresh_token: s,
|
|
1354
|
-
grant_type: "refresh_token"
|
|
1355
|
-
}, d = await (await fetch(`${this.domain}/connect/token`, {
|
|
1356
|
-
method: "POST",
|
|
1357
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
1358
|
-
body: JSON.stringify(a)
|
|
1359
|
-
})).json();
|
|
1360
|
-
if (d) {
|
|
1361
|
-
if (d.error) {
|
|
1362
|
-
const g = { detail: d };
|
|
1363
|
-
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", g)), !0;
|
|
1364
|
-
}
|
|
1365
|
-
const c = getTimestamp();
|
|
1366
|
-
if (d.expires_in = c + d.expires_in, this.Storage.setGrant(d, this.multiAccount), !await this.validateIDToken(t)) {
|
|
1367
|
-
const g = { detail: d };
|
|
1368
|
-
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", g)), !0;
|
|
1369
|
-
}
|
|
1370
|
-
const f = { detail: d };
|
|
1371
|
-
return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess", f)), !0;
|
|
1372
|
-
}
|
|
1373
|
-
this.Storage.removePKCE();
|
|
1374
|
-
} catch (a) {
|
|
1375
|
-
const l = { detail: a };
|
|
1376
|
-
return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", l)), !1;
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
// Handles the response of code exchange
|
|
1380
|
-
async handleCodeExchangeResponse(t) {
|
|
1381
|
-
if (t.error)
|
|
1382
|
-
return {
|
|
1383
|
-
data: t,
|
|
1384
|
-
valid: !1
|
|
1385
|
-
};
|
|
1386
|
-
const s = getTimestamp();
|
|
1387
|
-
t.expires_in = s + t.expires_in, this.Storage.setGrant(t, this.multiAccount);
|
|
1388
|
-
const a = o(t.id_token);
|
|
1389
|
-
return a.status = "authenticated", this.Storage.setUserToken(a), await this.validateIDToken(a.sub) ? {
|
|
1390
|
-
data: t,
|
|
1391
|
-
valid: !0
|
|
1392
|
-
} : {
|
|
1393
|
-
data: t,
|
|
1394
|
-
valid: !1
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
// Regulates POPUP behaivior
|
|
1398
|
-
async popUp(t) {
|
|
1399
|
-
const a = window.screenX + (window.outerWidth - 500) / 2, l = window.screenY + (window.outerHeight - 600) / 2.5, d = "uas-popup", c = t, u = window.open(c, d, `width=500,height=600,left=${a},top=${l}`);
|
|
1400
|
-
if (!u)
|
|
1401
|
-
return;
|
|
1402
|
-
const f = setInterval(async () => {
|
|
1403
|
-
if (u.closed) {
|
|
1404
|
-
const g = {
|
|
1405
|
-
detail: { error_description: "OAuth provider window closed" }
|
|
1406
|
-
};
|
|
1407
|
-
window.dispatchEvent(new CustomEvent("onLoginFail", g)), f && clearInterval(f);
|
|
1408
|
-
return;
|
|
1409
|
-
}
|
|
1410
|
-
try {
|
|
1411
|
-
const g = u.location.href.split("?");
|
|
1412
|
-
if (!g[0])
|
|
1413
|
-
return;
|
|
1414
|
-
const p = u.location.search;
|
|
1415
|
-
if (u.history.pushState({}, document.title, window.location.pathname), g[0] === this.redirectUri && g.length > 1) {
|
|
1416
|
-
const m = await this.codeExchange(p);
|
|
1417
|
-
u.close(), m && location.reload(), f && clearInterval(f);
|
|
1418
|
-
return;
|
|
1419
|
-
}
|
|
1420
|
-
} catch {
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
}, 1e3);
|
|
1424
|
-
}
|
|
1425
|
-
// Returns access token
|
|
1426
|
-
async getAccessToken(t = "") {
|
|
1427
|
-
const n = getTimestamp(), s = await this.Storage.getGrant(t, this.multiAccount);
|
|
1428
|
-
if (!s)
|
|
1429
|
-
return null;
|
|
1430
|
-
const { access_token: a, expires_in: l } = s, d = a;
|
|
1431
|
-
return d && l && l > getTimestamp() && l - n > 30 ? d : (await this.tokenExchange(t), (await this.Storage.getGrant(t, this.multiAccount)).access_token);
|
|
1432
|
-
}
|
|
1433
|
-
async sse(t, n) {
|
|
1434
|
-
const s = n.headers || {}, a = s["Grant-ID"];
|
|
1435
|
-
let l = "";
|
|
1436
|
-
if (this.multiAccount) {
|
|
1437
|
-
if (!a)
|
|
1438
|
-
throw this.logout(), new Error("Grant ID is required for multi account calls");
|
|
1439
|
-
l = await this.getAccessToken(a);
|
|
1440
|
-
} else
|
|
1441
|
-
l = await this.getAccessToken();
|
|
1442
|
-
return delete s["Grant-ID"], s.Authorization = `Bearer ${l}`, s["content-type"] || (s["content-type"] = "application/json"), fetchEventSource(`${this.domain}/${t}`, {
|
|
1443
|
-
...n,
|
|
1444
|
-
headers: s
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
// Used to call Nylas API endpoints
|
|
1448
|
-
async fetch(t, n, s = !0, a) {
|
|
1449
|
-
let l = "", d = 1;
|
|
1450
|
-
if (this.multiAccount) {
|
|
1451
|
-
if (!n.grant_id)
|
|
1452
|
-
throw this.logout(), new Error("Grant ID is required for multi account calls");
|
|
1453
|
-
const u = await this.getProfiles();
|
|
1454
|
-
d = u ? u.length : 1, l = await this.getAccessToken(n.grant_id);
|
|
1455
|
-
} else
|
|
1456
|
-
l = await this.getAccessToken();
|
|
1457
|
-
if (!l)
|
|
1458
|
-
throw new Error("Access token not found");
|
|
1459
|
-
let c = n.headers;
|
|
1460
|
-
Headers.prototype.isPrototypeOf(c) ? (c.append("Authorization", `Bearer ${l}`), c.has("content-type") || c.append("content-type", "application/json")) : c = new Headers({
|
|
1461
|
-
Authorization: `Bearer ${l}`,
|
|
1462
|
-
"content-type": "application/json"
|
|
1463
|
-
});
|
|
1464
|
-
try {
|
|
1465
|
-
n != null && n.body && (n.body = JSON.stringify(n == null ? void 0 : n.body));
|
|
1466
|
-
const u = await fetch(`${a || this.domain}/${t}`, {
|
|
1467
|
-
...n,
|
|
1468
|
-
headers: c
|
|
1469
|
-
});
|
|
1470
|
-
if (!s)
|
|
1471
|
-
return u;
|
|
1472
|
-
const f = await (u == null ? void 0 : u.json());
|
|
1473
|
-
if (!await this.isAuthenticatedResponse(u.status, f)) {
|
|
1474
|
-
if (d > 1) {
|
|
1475
|
-
const p = await this.getProfile(n.grant_id);
|
|
1476
|
-
if (p) {
|
|
1477
|
-
p.status = "unauthorized", await this.Storage.setUserToken(p);
|
|
1478
|
-
const m = {
|
|
1479
|
-
detail: { user: p }
|
|
1480
|
-
};
|
|
1481
|
-
window.dispatchEvent(new CustomEvent("onSessionExpired", m));
|
|
1482
|
-
}
|
|
1483
|
-
} else {
|
|
1484
|
-
const m = {
|
|
1485
|
-
detail: { user: await this.Storage.getUserToken() }
|
|
1486
|
-
};
|
|
1487
|
-
window.dispatchEvent(new CustomEvent("onSessionExpired", m));
|
|
1488
|
-
}
|
|
1489
|
-
this.logout();
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
return f;
|
|
1493
|
-
} catch (u) {
|
|
1494
|
-
throw u;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
async fetchRequest(t, n, s, a = !0, l, d) {
|
|
1498
|
-
const c = await this.isLoggedIn(), u = new URL(t, l ?? this.domain), f = new Headers();
|
|
1499
|
-
if (f.append("Accept", "application/json"), f.append("Content-Type", "application/json"), f.append("User-Agent", "nylas-identity"), c) {
|
|
1500
|
-
const m = await this.getAccessToken();
|
|
1501
|
-
f.append("Authorization", `Bearer ${m}`);
|
|
1502
|
-
}
|
|
1503
|
-
const g = await fetch(u.toString(), {
|
|
1504
|
-
method: n || "GET",
|
|
1505
|
-
headers: f,
|
|
1506
|
-
mode: "cors",
|
|
1507
|
-
referrer: location.origin,
|
|
1508
|
-
body: s ? JSON.stringify(s) : void 0,
|
|
1509
|
-
...d || {}
|
|
1510
|
-
});
|
|
1511
|
-
return a ? await g.json() : g.body;
|
|
1512
|
-
}
|
|
1513
|
-
// Checks if the response is not 401
|
|
1514
|
-
async isAuthenticatedResponse(t, n) {
|
|
1515
|
-
var s;
|
|
1516
|
-
return !(t == 401 && ((s = n == null ? void 0 : n.error) == null ? void 0 : s.type) == "token.unauthorized_access");
|
|
1517
|
-
}
|
|
1518
|
-
addAPIKey(t, n, s) {
|
|
1519
|
-
this.Storage.setUserToken({
|
|
1520
|
-
aud: "https://api-staging.us.nylas.com/",
|
|
1521
|
-
exp: 2e9,
|
|
1522
|
-
email_verified: !0,
|
|
1523
|
-
iat: getTimestamp(),
|
|
1524
|
-
iss: "",
|
|
1525
|
-
email: n,
|
|
1526
|
-
provider: "virtual-calendar",
|
|
1527
|
-
status: "authenticated",
|
|
1528
|
-
name: n,
|
|
1529
|
-
sub: t
|
|
1530
|
-
}), this.Storage.setGrant({
|
|
1531
|
-
grant_id: t,
|
|
1532
|
-
access_token: s,
|
|
1533
|
-
expires_in: 2e9
|
|
1534
|
-
}, this.multiAccount);
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
var B = { isMounted: function() {
|
|
1538
|
-
return !1;
|
|
1539
|
-
}, enqueueForceUpdate: function() {
|
|
1540
|
-
}, enqueueReplaceState: function() {
|
|
1541
|
-
}, enqueueSetState: function() {
|
|
1542
|
-
} }, C = Object.assign, D = {};
|
|
1543
|
-
function E(r, t, n) {
|
|
1544
|
-
this.props = r, this.context = t, this.refs = D, this.updater = n || B;
|
|
1545
|
-
}
|
|
1546
|
-
E.prototype.isReactComponent = {};
|
|
1547
|
-
E.prototype.setState = function(r, t) {
|
|
1548
|
-
if (typeof r != "object" && typeof r != "function" && r != null)
|
|
1549
|
-
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
1550
|
-
this.updater.enqueueSetState(this, r, t, "setState");
|
|
1551
|
-
};
|
|
1552
|
-
E.prototype.forceUpdate = function(r) {
|
|
1553
|
-
this.updater.enqueueForceUpdate(this, r, "forceUpdate");
|
|
1554
|
-
};
|
|
1555
|
-
function F() {
|
|
1556
|
-
}
|
|
1557
|
-
F.prototype = E.prototype;
|
|
1558
|
-
function G(r, t, n) {
|
|
1559
|
-
this.props = r, this.context = t, this.refs = D, this.updater = n || B;
|
|
1560
|
-
}
|
|
1561
|
-
var H = G.prototype = new F();
|
|
1562
|
-
H.constructor = G;
|
|
1563
|
-
C(H, E.prototype);
|
|
1564
|
-
H.isPureReactComponent = !0;
|
|
1565
|
-
const LoginRequired = ({ authenticationUrl: r }) => h(
|
|
1566
|
-
"div",
|
|
1567
|
-
{ class: "login-required", part: "nse__login-required login-component" },
|
|
1568
|
-
h(
|
|
1569
|
-
"div",
|
|
1570
|
-
{ class: "card", part: "nse__login-required-card" },
|
|
1571
|
-
h("p", { part: "nse__login-required-text" }, "Log into your account to use the Scheduler Editor."),
|
|
1572
|
-
h(
|
|
1573
|
-
"button",
|
|
1574
|
-
{ class: "google-button", part: "nse__login-required-google-button", onClick: async (t) => {
|
|
1575
|
-
t.preventDefault();
|
|
1576
|
-
const n = await r("google");
|
|
1577
|
-
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1578
|
-
} },
|
|
1579
|
-
h(
|
|
1580
|
-
"span",
|
|
1581
|
-
{ class: "icon" },
|
|
1582
|
-
h("google-logo-icon", { width: "15", height: "15" })
|
|
1583
|
-
),
|
|
1584
|
-
"Continue with Google"
|
|
1585
|
-
),
|
|
1586
|
-
h(
|
|
1587
|
-
"button",
|
|
1588
|
-
{ class: "microsoft-button", part: "nse__login-required-microsoft-button", onClick: async (t) => {
|
|
1589
|
-
t.preventDefault();
|
|
1590
|
-
const n = await r("microsoft");
|
|
1591
|
-
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1592
|
-
} },
|
|
1593
|
-
h(
|
|
1594
|
-
"span",
|
|
1595
|
-
{ class: "icon" },
|
|
1596
|
-
h("microsoft-logo-icon", { width: "15", height: "15" })
|
|
1597
|
-
),
|
|
1598
|
-
"Continue with Microsoft"
|
|
1599
|
-
),
|
|
1600
|
-
h(
|
|
1601
|
-
"button",
|
|
1602
|
-
{ class: "other-provider-button", part: "nse__login-required-other-provider-button", onClick: async (t) => {
|
|
1603
|
-
t.preventDefault();
|
|
1604
|
-
const n = await r();
|
|
1605
|
-
n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
|
|
1606
|
-
} },
|
|
1607
|
-
"View all providers ",
|
|
1608
|
-
h("chevron-icon", { width: "17", height: "17" })
|
|
1609
|
-
),
|
|
1610
|
-
h("small", { class: "disclaimer-text", part: "nse__login-required-disclaimer-text" }, "* You will be redirected to authenticate your account.")
|
|
1611
|
-
)
|
|
1612
|
-
);
|
|
1613
|
-
function ExpressFlow({ currentUser: r, calendars: t, selectedEventType: n }) {
|
|
1614
|
-
const s = (t == null ? void 0 : t.find((a) => a.is_primary)) || (t == null ? void 0 : t[0]);
|
|
1615
|
-
switch (n) {
|
|
1616
|
-
case CONFIGURATION_EVENT_TYPE.one_on_one:
|
|
1617
|
-
case CONFIGURATION_EVENT_TYPE.max_availability:
|
|
1618
|
-
case CONFIGURATION_EVENT_TYPE.max_fairness:
|
|
1619
|
-
return h(
|
|
1620
|
-
Fragment,
|
|
1621
|
-
null,
|
|
1622
|
-
h(
|
|
1623
|
-
"nylas-event-info",
|
|
1624
|
-
null,
|
|
1625
|
-
h(
|
|
1626
|
-
"div",
|
|
1627
|
-
{ slot: "inputs" },
|
|
1628
|
-
h("nylas-event-title", null),
|
|
1629
|
-
h("nylas-event-duration", null),
|
|
1630
|
-
h("nylas-event-location", { userProvider: r.provider })
|
|
1631
|
-
)
|
|
1632
|
-
),
|
|
1633
|
-
h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
|
|
1634
|
-
h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
|
|
1635
|
-
);
|
|
1636
|
-
case CONFIGURATION_EVENT_TYPE.collective:
|
|
1637
|
-
return h(
|
|
1638
|
-
Fragment,
|
|
1639
|
-
null,
|
|
1640
|
-
h(
|
|
1641
|
-
"nylas-event-info",
|
|
1642
|
-
null,
|
|
1643
|
-
h(
|
|
1644
|
-
"div",
|
|
1645
|
-
{ slot: "inputs" },
|
|
1646
|
-
h("nylas-event-title", null),
|
|
1647
|
-
h("nylas-event-duration", null),
|
|
1648
|
-
h("nylas-event-location", { userProvider: r.provider })
|
|
1649
|
-
)
|
|
1650
|
-
),
|
|
1651
|
-
h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
|
|
1652
|
-
h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" }),
|
|
1653
|
-
h("nylas-additional-participants", { name: "participants", eventParticipants: [{ name: (r == null ? void 0 : r.name) || (r == null ? void 0 : r.email), email: (r == null ? void 0 : r.email) || "", is_organizer: !0 }], exportparts: "nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant" })
|
|
1654
|
-
);
|
|
1655
|
-
case CONFIGURATION_EVENT_TYPE.group:
|
|
1656
|
-
return h(
|
|
1657
|
-
Fragment,
|
|
1658
|
-
null,
|
|
1659
|
-
h(
|
|
1660
|
-
"nylas-event-info",
|
|
1661
|
-
null,
|
|
1662
|
-
h(
|
|
1663
|
-
"div",
|
|
1664
|
-
{ slot: "inputs" },
|
|
1665
|
-
h("nylas-event-title", { noTemplates: !0 }),
|
|
1666
|
-
h("nylas-event-description", { noTemplates: !0, hideAutoPopulateButton: !0 }),
|
|
1667
|
-
h("nylas-event-location", { userProvider: r.provider }),
|
|
1668
|
-
h("nylas-event-timeslot", { name: "event-timeslot" }),
|
|
1669
|
-
h("nylas-event-capacity", null)
|
|
1670
|
-
)
|
|
1671
|
-
),
|
|
1672
|
-
h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
|
|
1673
|
-
h("nylas-additional-participants", { name: "participants", eventParticipants: [{ name: (r == null ? void 0 : r.name) || (r == null ? void 0 : r.email), email: (r == null ? void 0 : r.email) || "", is_organizer: !0 }], exportparts: "nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant" }),
|
|
1674
|
-
h("nylas-page-name", { requirePageName: !0, pageName: "Group events page" }),
|
|
1675
|
-
h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
|
|
1676
|
-
);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
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-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--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-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}@media screen and (max-width: 768px){:host{width:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}:host nylas-notification{position:absolute;top:0;right:0}div.scheduler-editor-content{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}div.scheduler-editor-content slot[name=login-required]{height:inherit}div.scheduler-editor-content--group{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content--group{height:auto}}div.scheduler-editor-header{display:grid;grid-template-columns:1fr auto auto;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900);min-width:924px}@media screen and (max-width: 768px){div.scheduler-editor-header{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;margin:0;font-size:18px;line-height:24px;font-weight:600}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer;color:var(--nylas-base-900)}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary);background-color:transparent}div.scheduler-editor-header button:disabled{cursor:not-allowed}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button){border:none;padding:4px;margin-right:8px}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button):hover{outline:none;color:var(--nylas-primary)}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){min-width:132px}@media screen and (max-width: 768px){div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){width:-webkit-fill-available;width:fill-available;width:-moz-available}}nylas-select-event-type{height:inherit;width:calc(924px + 2rem)}@media screen and (max-width: 768px){nylas-select-event-type{width:auto}}nylas-editor-tabs,nylas-editor-tabs-group{width:auto;height:inherit}nylas-editor-tabs .row,nylas-editor-tabs-group .row{display:flex;gap:1rem}nylas-editor-tabs .composable,nylas-editor-tabs-group .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs],nylas-editor-tabs-group nylas-event-info div[slot=inputs],nylas-editor-tabs-group 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;color:var(--nylas-base-900);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:16px;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;color:var(--nylas-base-900)}.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:16px;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;color:var(--nylas-base-900)}.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;padding:2rem 1rem}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}', NylasSchedulerEditorStyle0 = nylasSchedulerEditorCss, NylasSchedulerEditor = class {
|
|
1680
|
-
constructor(r) {
|
|
1681
|
-
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) => {
|
|
1682
|
-
const n = this.schedulerConfigCloseClicked.emit(this.host);
|
|
1683
|
-
"schedulerConfigCloseClicked" in this.eventOverrides && this.eventOverrides.schedulerConfigCloseClicked(n, this.nylasSchedulerConfigConnector), n.defaultPrevented || (localStorage.removeItem("grant"), localStorage.removeItem("user"), window.location.reload());
|
|
1684
|
-
}, 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.enableUserFeedback = !0, this.defaultLanguage = void 0, this.localization = void 0, this.nylasBranding = !0, this.experimentalFeatures = void 0, this.enableEventTypes = {
|
|
1685
|
-
one_on_one: !0,
|
|
1686
|
-
collective: !0,
|
|
1687
|
-
max_fairness: !0,
|
|
1688
|
-
max_availability: !0,
|
|
1689
|
-
group: !0
|
|
1690
|
-
}, this.themeConfig = void 0, this.automaticComponentRegistration = !0, this.selectedLanguage = this.defaultLanguage || LANGUAGE_CODE.en, this.langVersion = 0, this.version = "2.1.0";
|
|
1691
|
-
}
|
|
1692
|
-
connectedCallback() {
|
|
1693
|
-
debug("[nylas-scheduler-editor] connectedCallback");
|
|
1694
|
-
}
|
|
1695
|
-
async componentWillLoad() {
|
|
1696
|
-
var s, a, l, d, c, u, f, g;
|
|
1697
|
-
debug("[nylas-scheduler-editor] componentWillLoad");
|
|
1698
|
-
const r = (s = this.additionalParticipants) == null ? void 0 : s.filter((p) => {
|
|
1699
|
-
var y;
|
|
1700
|
-
const m = ((y = p.calendars) == null ? void 0 : y.length) > 0 ? p.calendars.filter((w) => w.id && w.name) : [];
|
|
1701
|
-
if (p.name && p.email && m.length > 0)
|
|
1702
|
-
return {
|
|
1703
|
-
name: p.name,
|
|
1704
|
-
email: p.email,
|
|
1705
|
-
calendars: m
|
|
1706
|
-
};
|
|
1707
|
-
});
|
|
1708
|
-
if (this.stores = {
|
|
1709
|
-
schedulerConfig: CreateNylasSchedulerConfigStore({
|
|
1710
|
-
...this.defaultSchedulerConfigState,
|
|
1711
|
-
additionalParticipants: r,
|
|
1712
|
-
conferenceProviders: this.conferenceProviders,
|
|
1713
|
-
requiresSlug: this.requiresSlug,
|
|
1714
|
-
selectedLanguage: this.defaultLanguage || LANGUAGE_CODE.en,
|
|
1715
|
-
nylasBranding: this.nylasBranding,
|
|
1716
|
-
experimentalFeatures: this.experimentalFeatures,
|
|
1717
|
-
enableEventTypes: this.enableEventTypes,
|
|
1718
|
-
themeConfig: this.themeConfig
|
|
1719
|
-
})
|
|
1720
|
-
}, !this.nylasApiRequest && this.nylasSessionsConfig) {
|
|
1721
|
-
const p = new NylasSessions(this.nylasSessionsConfig);
|
|
1722
|
-
await p.isLoggedIn(), p.onLoginSuccess(async () => {
|
|
1723
|
-
var y, w;
|
|
1724
|
-
const m = await ((w = (y = this.nylasSchedulerConfigConnector) == null ? void 0 : y.schedulerConfig) == null ? void 0 : w.currentUser());
|
|
1725
|
-
if (m) {
|
|
1726
|
-
const v = this.loggedIn.emit(this.host);
|
|
1727
|
-
"loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(v, this.nylasSchedulerConfigConnector), v.defaultPrevented || await this.loggedInHandler(m);
|
|
1728
|
-
}
|
|
1729
|
-
}), p.onLoginFail(async () => {
|
|
1730
|
-
var y, w;
|
|
1731
|
-
(w = (y = this.stores) == null ? void 0 : y.schedulerConfig) == null || w.set("currentUser", null);
|
|
1732
|
-
const m = this.loggedOut.emit(this.host);
|
|
1733
|
-
"loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented);
|
|
1734
|
-
}), this.nylasApiRequest = new NylasIdentityRequestWrapper(p);
|
|
1735
|
-
}
|
|
1736
|
-
this.nylasApiRequest && this.defaultAuthArgs && this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs), this.baseProvider = new NylasBaseProvider(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
|
|
1737
|
-
const t = this.baseProvider.getStore("schedulerConfig");
|
|
1738
|
-
this.nylasSchedulerConfigConnector = new NylasSchedulerConfigConnector({
|
|
1739
|
-
nylasApiRequest: this.nylasApiRequest,
|
|
1740
|
-
nylasSchedulerConfigStore: t
|
|
1741
|
-
});
|
|
1742
|
-
const n = this.init.emit(this.host);
|
|
1743
|
-
if ("init" in this.eventOverrides && await this.eventOverrides.init(n, this.nylasSchedulerConfigConnector), !n.defaultPrevented) {
|
|
1744
|
-
const p = await ((l = (a = this.nylasSchedulerConfigConnector) == null ? void 0 : a.schedulerConfig) == null ? void 0 : l.currentUser());
|
|
1745
|
-
if (p) {
|
|
1746
|
-
const m = this.loggedIn.emit(this.host);
|
|
1747
|
-
"loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(m, this.nylasSchedulerConfigConnector), m.defaultPrevented || await this.loggedInHandler(p);
|
|
1748
|
-
} else {
|
|
1749
|
-
(c = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || c.set("currentUser", null);
|
|
1750
|
-
const m = this.loggedOut.emit(this.host);
|
|
1751
|
-
if ("loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented))
|
|
1752
|
-
return;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
(f = (u = this.stores) == null ? void 0 : u.schedulerConfig) == null || f.onChange("selectedConfiguration", async (p) => {
|
|
1756
|
-
p && p.id && (this.configurationId = p.id);
|
|
1757
|
-
}), (g = this.baseProvider) == null || g.componentWillLoad(this.nylasSchedulerConfigConnector), this.applyThemeConfig(this.themeConfig);
|
|
1758
|
-
}
|
|
1759
|
-
async componentDidLoad() {
|
|
1760
|
-
var r;
|
|
1761
|
-
debug("[nylas-scheduler-editor] componentDidLoad"), await ((r = this.baseProvider) == null ? void 0 : r.componentDidLoad()), this.updateLocalization(this.localization), this.version = "2.1.0";
|
|
1762
|
-
}
|
|
1763
|
-
async componentDisconnected() {
|
|
1764
|
-
var r;
|
|
1765
|
-
await ((r = this.baseProvider) == null ? void 0 : r.componentDisconnected());
|
|
1766
|
-
}
|
|
1767
|
-
async configurationIdChanged(r) {
|
|
1768
|
-
var t, n, s, a, l, d, c, u;
|
|
1769
|
-
r ? (await ((n = (t = this.nylasSchedulerConfigConnector) == null ? void 0 : t.schedulerConfig) == null ? void 0 : n.getConfigurationById(r)), (a = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || a.set("action", "edit")) : ((d = (l = this.stores) == null ? void 0 : l.schedulerConfig) == null || d.set("selectedConfiguration", {}), (u = (c = this.stores) == null ? void 0 : c.schedulerConfig) == null || u.set("action", null));
|
|
1770
|
-
}
|
|
1771
|
-
updateLocalization(r) {
|
|
1772
|
-
r && (Object.keys(r).forEach((t) => {
|
|
1773
|
-
t in LANGUAGE_CODE && instance.addResourceBundle(t, "translation", r[t], !1, !0);
|
|
1774
|
-
}), this.langVersion++);
|
|
1775
|
-
}
|
|
1776
|
-
updateNylasBranding(r) {
|
|
1777
|
-
var t, n;
|
|
1778
|
-
(n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("nylasBranding", r);
|
|
1779
|
-
}
|
|
1780
|
-
updateExperimentalFeatures(r) {
|
|
1781
|
-
var t, n;
|
|
1782
|
-
(n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("experimentalFeatures", r);
|
|
1783
|
-
}
|
|
1784
|
-
updateEnableEventTypes(r) {
|
|
1785
|
-
var t, n;
|
|
1786
|
-
(n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("enableEventTypes", r);
|
|
1787
|
-
}
|
|
1788
|
-
themeConfigChanged(r) {
|
|
1789
|
-
var t, n;
|
|
1790
|
-
(n = (t = this.baseProvider) == null ? void 0 : t.getStore("schedulerConfig")) == null || n.set("themeConfig", r), this.applyThemeConfig(r);
|
|
1791
|
-
}
|
|
1792
|
-
applyThemeConfig(r) {
|
|
1793
|
-
if (r)
|
|
1794
|
-
for (const [t, n] of Object.entries(r))
|
|
1795
|
-
this.host.style.setProperty(`${t}`, n);
|
|
1796
|
-
}
|
|
1797
|
-
async store() {
|
|
1798
|
-
var r;
|
|
1799
|
-
return (r = this.stores) == null ? void 0 : r.schedulerConfig;
|
|
1800
|
-
}
|
|
1801
|
-
async schedulerConnector() {
|
|
1802
|
-
return this.nylasSchedulerConfigConnector;
|
|
1803
|
-
}
|
|
1804
|
-
async registerComponentHandler(r) {
|
|
1805
|
-
var t;
|
|
1806
|
-
(t = this.baseProvider) == null || t.registerComponent(r.detail);
|
|
1807
|
-
}
|
|
1808
|
-
async unregisterComponentHandler(r) {
|
|
1809
|
-
var t;
|
|
1810
|
-
(t = this.baseProvider) == null || t.unregisterComponent(r.detail);
|
|
1811
|
-
}
|
|
1812
|
-
nylasFormDropdownChangedHandler(r) {
|
|
1813
|
-
var s, a;
|
|
1814
|
-
const { name: t, value: n } = r.detail;
|
|
1815
|
-
t === "language" && (this.selectedLanguage = LANGUAGE_CODE[n], instance.changeLanguage(this.selectedLanguage), (a = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || a.set("selectedLanguage", this.selectedLanguage));
|
|
1816
|
-
}
|
|
1817
|
-
async loggedInHandler(r) {
|
|
1818
|
-
var t, n, s, a, l, d, c;
|
|
1819
|
-
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)) {
|
|
1820
|
-
const u = await ((a = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : a.getConfigurationById(this.configurationId));
|
|
1821
|
-
u && ((l = u[0]) != null && l.id) && ((c = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || c.set("action", "edit"));
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
render() {
|
|
1825
|
-
var a, l, d, c, u, f, g, p, m, y, w, v, x, R, A, I, U, N, O, k, T, S, _, L, b, $, X, j, z, Y, M, V, J, W, Z, Q, ee, te, ne, se, re, ie, oe, ae;
|
|
1826
|
-
const r = this.host.querySelector('[slot="custom-page-style-inputs"]'), t = (d = (l = (a = this.stores) == null ? void 0 : a.schedulerConfig) == null ? void 0 : l.state.selectedConfiguration) == null ? void 0 : d.id, n = Object.keys(LANGUAGE_MAP).map((q) => ({
|
|
1827
|
-
label: LANGUAGE_MAP[q],
|
|
1828
|
-
value: q
|
|
1829
|
-
})), s = ((u = (c = this.stores) == null ? void 0 : c.schedulerConfig) == null ? void 0 : u.state.selectedEventType) === CONFIGURATION_EVENT_TYPE.group || ((p = (g = (f = this.stores) == null ? void 0 : f.schedulerConfig) == null ? void 0 : g.state.selectedConfiguration) == null ? void 0 : p.type) === CONFIGURATION_EVENT_TYPE.group;
|
|
1830
|
-
return h(Host, { key: "8125ba9d8bbd8c1604ec4e57d769882137c7a6c5" }, h("div", { key: "51222baddda6bd200080440ac46c390b5c754734", class: "scheduler-editor-header", part: "nse__header" }, h("h1", { key: "91e8379a5068634421d8f272a5251ab578496e05", class: "scheduler-editor-title", part: "nse__title" }, h("calendar-icon", { key: "1c040d10dff4fc86d257e446c8228033b9a02032", width: "18", height: "18" }), instance.t("schedulerEditorTitle"), h("tooltip-component", { key: "1e6c30c0958fbc8dde357d03c597eb70ce35271f" }, h("info-icon", { key: "4ebd6aea27a62c33849659066860c5de75c0b7c7", slot: "tooltip-icon" }), h("span", { key: "4ddc14ba968a1d0053f5a5fb07473333186a8476", slot: "tooltip-content" }, this.version))), h("div", { key: "679bbc03e8d3e155f843ae86af0ec037ee8c2d05", class: {
|
|
1831
|
-
language: !0
|
|
1832
|
-
}, part: "nse__language" }, h("select-dropdown", { key: "9f788d9d39f2a190ef388cacca206374e19da11c", name: "language", searchPlaceholder: instance.t("search"), options: n, withChevron: !1, themeConfig: this.themeConfig, defaultSelectedOption: n.find((q) => q.value == this.selectedLanguage), exportparts: "sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label" }, h("span", { key: "76aa9b5b9adea974e1e8a7ac1f47faee3fc8a320", slot: "select-icon" }, h("translate-icon", { key: "9dd3b210004d04b42c3d0209db60414c6c86c54c", width: "20", height: "20" })))), h("button", { key: "fa401a8ffb5f77caae60852e7a7be15f21868002", class: "scheduler-editor-close", title: "logout", onClick: (q) => this.handleSchedulerConfigCloseClicked(q), part: "nse__close-button" }, h("close-icon", { key: "96135ba113ecdad2d3223cc8df293d46b62565e5", width: "18", height: "18" }))), h("div", { key: "48970044629cfeafd07b4ccdb34e8d3ab67e0076", class: {
|
|
1833
|
-
"scheduler-editor-content": !0,
|
|
1834
|
-
"scheduler-editor-content--group": s
|
|
1835
|
-
}, part: "nse__content" }, ((y = (m = this.stores) == null ? void 0 : m.schedulerConfig) == null ? void 0 : y.state.currentUser) && this.stores.schedulerConfig.state.action === null && h("div", { class: "list-configurations", part: "nse__list-configurations" }, h("nylas-list-configurations", { exportparts: "nlc__create-new-cta, actions__dropdown, actions__dropdown-button, actions__dropdown-content, actions-Copy, actions-Preview, actions-Delete" })), ((v = (w = this.stores) == null ? void 0 : w.schedulerConfig) == null ? void 0 : v.state.currentUser) && this.stores.schedulerConfig.state.action === "create-select" && h("nylas-select-event-type", null), ((R = (x = this.stores) == null ? void 0 : x.schedulerConfig) == null ? void 0 : R.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && s && h("nylas-editor-tabs-group", { mode: "composable" }, h(ExpressFlow, { selectedEventType: ((U = (I = (A = this.stores) == null ? void 0 : A.schedulerConfig) == null ? void 0 : I.state) == null ? void 0 : U.selectedEventType) || CONFIGURATION_EVENT_TYPE.one_on_one, currentUser: (O = (N = this.stores) == null ? void 0 : N.schedulerConfig) == null ? void 0 : O.state.currentUser, calendars: (S = (T = (k = this.stores) == null ? void 0 : k.schedulerConfig) == null ? void 0 : T.state) == null ? void 0 : S.calendars, selectedConfiguration: (b = (L = (_ = this.stores) == null ? void 0 : _.schedulerConfig) == null ? void 0 : L.state) == null ? void 0 : b.selectedConfiguration })), ((X = ($ = this.stores) == null ? void 0 : $.schedulerConfig) == null ? void 0 : X.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && !s && h("nylas-editor-tabs", { mode: "composable" }, h(ExpressFlow, { selectedEventType: ((Y = (z = (j = this.stores) == null ? void 0 : j.schedulerConfig) == null ? void 0 : z.state) == null ? void 0 : Y.selectedEventType) || CONFIGURATION_EVENT_TYPE.one_on_one, currentUser: (V = (M = this.stores) == null ? void 0 : M.schedulerConfig) == null ? void 0 : V.state.currentUser, calendars: (Z = (W = (J = this.stores) == null ? void 0 : J.schedulerConfig) == null ? void 0 : W.state) == null ? void 0 : Z.calendars, selectedConfiguration: (te = (ee = (Q = this.stores) == null ? void 0 : Q.schedulerConfig) == null ? void 0 : ee.state) == null ? void 0 : te.selectedConfiguration })), ((se = (ne = this.stores) == null ? void 0 : ne.schedulerConfig) == null ? void 0 : se.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && s && h("nylas-editor-tabs-group", { key: t, mode: this.mode }, this.mode === "composable" && h("slot", null), this.mode === "app" && r && h("div", { style: { display: "none" }, slot: "custom-page-style-inputs", key: t }, h("slot", { name: "custom-page-style-inputs" }))), ((ie = (re = this.stores) == null ? void 0 : re.schedulerConfig) == null ? void 0 : ie.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && !s && h("nylas-editor-tabs", { key: t, mode: this.mode }, this.mode === "composable" && h("slot", null), this.mode === "app" && r && h("div", { style: { display: "none" }, slot: "custom-page-style-inputs", key: t }, h("slot", { name: "custom-page-style-inputs" }))), !((ae = (oe = this.stores) == null ? void 0 : oe.schedulerConfig) != null && ae.state.currentUser) && h("slot", { name: "login-required" }, h(LoginRequired, { authenticationUrl: this.authenticationUrl }))));
|
|
1836
|
-
}
|
|
1837
|
-
get host() {
|
|
1838
|
-
return getElement(this);
|
|
1839
|
-
}
|
|
1840
|
-
static get watchers() {
|
|
1841
|
-
return {
|
|
1842
|
-
configurationId: ["configurationIdChanged"],
|
|
1843
|
-
localization: ["updateLocalization"],
|
|
1844
|
-
nylasBranding: ["updateNylasBranding"],
|
|
1845
|
-
experimentalFeatures: ["updateExperimentalFeatures"],
|
|
1846
|
-
enableEventTypes: ["updateEnableEventTypes"],
|
|
1847
|
-
themeConfig: ["themeConfigChanged"]
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
1851
|
-
NylasSchedulerEditor.style = NylasSchedulerEditorStyle0;
|
|
1852
|
-
export {
|
|
1853
|
-
NylasSchedulerEditor as nylas_scheduler_editor
|
|
1854
|
-
};
|