@wral/studio.mods.auth 1.0.0 → 1.0.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/bitbucket-pipelines.yml +3 -3
- package/dist/auth.cjs.js +20 -20
- package/dist/auth.es.js +263 -252
- package/package.json +1 -1
- package/vite.config.mjs +1 -1
package/dist/auth.es.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import { getToken as
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
import { getToken as G } from "./lib.es.js";
|
|
2
|
+
function be(s, e) {
|
|
3
|
+
var o, i;
|
|
4
|
+
const r = e.element.attributes;
|
|
5
|
+
return console.log(r), {
|
|
6
|
+
api: r.api.value || ve("auth:api is required"),
|
|
7
|
+
forceLogin: r["force-login"] !== void 0,
|
|
8
|
+
// TODO: handle false
|
|
9
|
+
storageKey: (o = r["storage-key"]) == null ? void 0 : o.value,
|
|
10
|
+
mount: ((i = r.path) == null ? void 0 : i.value) || "/auth",
|
|
11
|
+
toolkit: s
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function ve(s) {
|
|
15
|
+
throw new Error(s);
|
|
16
|
+
}
|
|
17
|
+
function k(s, ...e) {
|
|
18
|
+
return (...t) => s(...e, ...t);
|
|
4
19
|
}
|
|
5
20
|
/**
|
|
6
21
|
* @license
|
|
7
22
|
* Copyright 2019 Google LLC
|
|
8
23
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
24
|
*/
|
|
10
|
-
const F = globalThis,
|
|
25
|
+
const F = globalThis, K = F.ShadowRoot && (F.ShadyCSS === void 0 || F.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Q = Symbol(), Z = /* @__PURE__ */ new WeakMap();
|
|
11
26
|
let ce = class {
|
|
12
|
-
constructor(e, t,
|
|
13
|
-
if (this._$cssResult$ = !0,
|
|
27
|
+
constructor(e, t, r) {
|
|
28
|
+
if (this._$cssResult$ = !0, r !== Q) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
14
29
|
this.cssText = e, this.t = t;
|
|
15
30
|
}
|
|
16
31
|
get styleSheet() {
|
|
17
32
|
let e = this.o;
|
|
18
33
|
const t = this.t;
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
|
|
34
|
+
if (K && e === void 0) {
|
|
35
|
+
const r = t !== void 0 && t.length === 1;
|
|
36
|
+
r && (e = Z.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), r && Z.set(t, e));
|
|
22
37
|
}
|
|
23
38
|
return e;
|
|
24
39
|
}
|
|
@@ -26,59 +41,59 @@ let ce = class {
|
|
|
26
41
|
return this.cssText;
|
|
27
42
|
}
|
|
28
43
|
};
|
|
29
|
-
const
|
|
30
|
-
const t =
|
|
44
|
+
const _e = (s) => new ce(typeof s == "string" ? s : s + "", void 0, Q), q = (s, ...e) => {
|
|
45
|
+
const t = s.length === 1 ? s[0] : e.reduce((r, o, i) => r + ((n) => {
|
|
31
46
|
if (n._$cssResult$ === !0) return n.cssText;
|
|
32
47
|
if (typeof n == "number") return n;
|
|
33
48
|
throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
|
|
34
|
-
})(o) +
|
|
35
|
-
return new ce(t,
|
|
36
|
-
},
|
|
37
|
-
if (
|
|
49
|
+
})(o) + s[i + 1], s[0]);
|
|
50
|
+
return new ce(t, s, Q);
|
|
51
|
+
}, Ae = (s, e) => {
|
|
52
|
+
if (K) s.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
|
|
38
53
|
else for (const t of e) {
|
|
39
|
-
const
|
|
40
|
-
o !== void 0 &&
|
|
54
|
+
const r = document.createElement("style"), o = F.litNonce;
|
|
55
|
+
o !== void 0 && r.setAttribute("nonce", o), r.textContent = t.cssText, s.appendChild(r);
|
|
41
56
|
}
|
|
42
|
-
}, X =
|
|
57
|
+
}, X = K ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((e) => {
|
|
43
58
|
let t = "";
|
|
44
|
-
for (const
|
|
45
|
-
return
|
|
46
|
-
})(
|
|
59
|
+
for (const r of e.cssRules) t += r.cssText;
|
|
60
|
+
return _e(t);
|
|
61
|
+
})(s) : s;
|
|
47
62
|
/**
|
|
48
63
|
* @license
|
|
49
64
|
* Copyright 2017 Google LLC
|
|
50
65
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
66
|
*/
|
|
52
|
-
const { is:
|
|
67
|
+
const { is: Ee, defineProperty: Pe, getOwnPropertyDescriptor: Se, getOwnPropertyNames: Ce, getOwnPropertySymbols: xe, getPrototypeOf: ke } = Object, $ = globalThis, ee = $.trustedTypes, Te = ee ? ee.emptyScript : "", z = $.reactiveElementPolyfillSupport, U = (s, e) => s, V = { toAttribute(s, e) {
|
|
53
68
|
switch (e) {
|
|
54
69
|
case Boolean:
|
|
55
|
-
|
|
70
|
+
s = s ? Te : null;
|
|
56
71
|
break;
|
|
57
72
|
case Object:
|
|
58
73
|
case Array:
|
|
59
|
-
|
|
74
|
+
s = s == null ? s : JSON.stringify(s);
|
|
60
75
|
}
|
|
61
|
-
return
|
|
62
|
-
}, fromAttribute(
|
|
63
|
-
let t =
|
|
76
|
+
return s;
|
|
77
|
+
}, fromAttribute(s, e) {
|
|
78
|
+
let t = s;
|
|
64
79
|
switch (e) {
|
|
65
80
|
case Boolean:
|
|
66
|
-
t =
|
|
81
|
+
t = s !== null;
|
|
67
82
|
break;
|
|
68
83
|
case Number:
|
|
69
|
-
t =
|
|
84
|
+
t = s === null ? null : Number(s);
|
|
70
85
|
break;
|
|
71
86
|
case Object:
|
|
72
87
|
case Array:
|
|
73
88
|
try {
|
|
74
|
-
t = JSON.parse(
|
|
89
|
+
t = JSON.parse(s);
|
|
75
90
|
} catch {
|
|
76
91
|
t = null;
|
|
77
92
|
}
|
|
78
93
|
}
|
|
79
94
|
return t;
|
|
80
|
-
} }, de = (
|
|
81
|
-
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")),
|
|
95
|
+
} }, de = (s, e) => !Ee(s, e), te = { attribute: !0, type: String, converter: V, reflect: !1, hasChanged: de };
|
|
96
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $.litPropertyMetadata ?? ($.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
82
97
|
class P extends HTMLElement {
|
|
83
98
|
static addInitializer(e) {
|
|
84
99
|
this._$Ei(), (this.l ?? (this.l = [])).push(e);
|
|
@@ -88,12 +103,12 @@ class P extends HTMLElement {
|
|
|
88
103
|
}
|
|
89
104
|
static createProperty(e, t = te) {
|
|
90
105
|
if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
|
|
91
|
-
const
|
|
92
|
-
o !== void 0 &&
|
|
106
|
+
const r = Symbol(), o = this.getPropertyDescriptor(e, r, t);
|
|
107
|
+
o !== void 0 && Pe(this.prototype, e, o);
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
|
-
static getPropertyDescriptor(e, t,
|
|
96
|
-
const { get: o, set: i } =
|
|
110
|
+
static getPropertyDescriptor(e, t, r) {
|
|
111
|
+
const { get: o, set: i } = Se(this.prototype, e) ?? { get() {
|
|
97
112
|
return this[t];
|
|
98
113
|
}, set(n) {
|
|
99
114
|
this[t] = n;
|
|
@@ -102,7 +117,7 @@ class P extends HTMLElement {
|
|
|
102
117
|
return o == null ? void 0 : o.call(this);
|
|
103
118
|
}, set(n) {
|
|
104
119
|
const l = o == null ? void 0 : o.call(this);
|
|
105
|
-
i.call(this, n), this.requestUpdate(e, l,
|
|
120
|
+
i.call(this, n), this.requestUpdate(e, l, r);
|
|
106
121
|
}, configurable: !0, enumerable: !0 };
|
|
107
122
|
}
|
|
108
123
|
static getPropertyOptions(e) {
|
|
@@ -110,23 +125,23 @@ class P extends HTMLElement {
|
|
|
110
125
|
}
|
|
111
126
|
static _$Ei() {
|
|
112
127
|
if (this.hasOwnProperty(U("elementProperties"))) return;
|
|
113
|
-
const e =
|
|
128
|
+
const e = ke(this);
|
|
114
129
|
e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
|
|
115
130
|
}
|
|
116
131
|
static finalize() {
|
|
117
132
|
if (this.hasOwnProperty(U("finalized"))) return;
|
|
118
133
|
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(U("properties"))) {
|
|
119
|
-
const t = this.properties,
|
|
120
|
-
for (const o of
|
|
134
|
+
const t = this.properties, r = [...Ce(t), ...xe(t)];
|
|
135
|
+
for (const o of r) this.createProperty(o, t[o]);
|
|
121
136
|
}
|
|
122
137
|
const e = this[Symbol.metadata];
|
|
123
138
|
if (e !== null) {
|
|
124
139
|
const t = litPropertyMetadata.get(e);
|
|
125
|
-
if (t !== void 0) for (const [
|
|
140
|
+
if (t !== void 0) for (const [r, o] of t) this.elementProperties.set(r, o);
|
|
126
141
|
}
|
|
127
142
|
this._$Eh = /* @__PURE__ */ new Map();
|
|
128
|
-
for (const [t,
|
|
129
|
-
const o = this._$Eu(t,
|
|
143
|
+
for (const [t, r] of this.elementProperties) {
|
|
144
|
+
const o = this._$Eu(t, r);
|
|
130
145
|
o !== void 0 && this._$Eh.set(o, t);
|
|
131
146
|
}
|
|
132
147
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
@@ -134,14 +149,14 @@ class P extends HTMLElement {
|
|
|
134
149
|
static finalizeStyles(e) {
|
|
135
150
|
const t = [];
|
|
136
151
|
if (Array.isArray(e)) {
|
|
137
|
-
const
|
|
138
|
-
for (const o of
|
|
152
|
+
const r = new Set(e.flat(1 / 0).reverse());
|
|
153
|
+
for (const o of r) t.unshift(X(o));
|
|
139
154
|
} else e !== void 0 && t.push(X(e));
|
|
140
155
|
return t;
|
|
141
156
|
}
|
|
142
157
|
static _$Eu(e, t) {
|
|
143
|
-
const
|
|
144
|
-
return
|
|
158
|
+
const r = t.attribute;
|
|
159
|
+
return r === !1 ? void 0 : typeof r == "string" ? r : typeof e == "string" ? e.toLowerCase() : void 0;
|
|
145
160
|
}
|
|
146
161
|
constructor() {
|
|
147
162
|
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
@@ -160,18 +175,18 @@ class P extends HTMLElement {
|
|
|
160
175
|
}
|
|
161
176
|
_$E_() {
|
|
162
177
|
const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
|
|
163
|
-
for (const
|
|
178
|
+
for (const r of t.keys()) this.hasOwnProperty(r) && (e.set(r, this[r]), delete this[r]);
|
|
164
179
|
e.size > 0 && (this._$Ep = e);
|
|
165
180
|
}
|
|
166
181
|
createRenderRoot() {
|
|
167
182
|
const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
168
|
-
return
|
|
183
|
+
return Ae(e, this.constructor.elementStyles), e;
|
|
169
184
|
}
|
|
170
185
|
connectedCallback() {
|
|
171
186
|
var e;
|
|
172
187
|
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => {
|
|
173
|
-
var
|
|
174
|
-
return (
|
|
188
|
+
var r;
|
|
189
|
+
return (r = t.hostConnected) == null ? void 0 : r.call(t);
|
|
175
190
|
});
|
|
176
191
|
}
|
|
177
192
|
enableUpdating(e) {
|
|
@@ -179,38 +194,38 @@ class P extends HTMLElement {
|
|
|
179
194
|
disconnectedCallback() {
|
|
180
195
|
var e;
|
|
181
196
|
(e = this._$EO) == null || e.forEach((t) => {
|
|
182
|
-
var
|
|
183
|
-
return (
|
|
197
|
+
var r;
|
|
198
|
+
return (r = t.hostDisconnected) == null ? void 0 : r.call(t);
|
|
184
199
|
});
|
|
185
200
|
}
|
|
186
|
-
attributeChangedCallback(e, t,
|
|
187
|
-
this._$AK(e,
|
|
201
|
+
attributeChangedCallback(e, t, r) {
|
|
202
|
+
this._$AK(e, r);
|
|
188
203
|
}
|
|
189
204
|
_$EC(e, t) {
|
|
190
205
|
var i;
|
|
191
|
-
const
|
|
192
|
-
if (o !== void 0 &&
|
|
193
|
-
const n = (((i =
|
|
206
|
+
const r = this.constructor.elementProperties.get(e), o = this.constructor._$Eu(e, r);
|
|
207
|
+
if (o !== void 0 && r.reflect === !0) {
|
|
208
|
+
const n = (((i = r.converter) == null ? void 0 : i.toAttribute) !== void 0 ? r.converter : V).toAttribute(t, r.type);
|
|
194
209
|
this._$Em = e, n == null ? this.removeAttribute(o) : this.setAttribute(o, n), this._$Em = null;
|
|
195
210
|
}
|
|
196
211
|
}
|
|
197
212
|
_$AK(e, t) {
|
|
198
213
|
var i;
|
|
199
|
-
const
|
|
214
|
+
const r = this.constructor, o = r._$Eh.get(e);
|
|
200
215
|
if (o !== void 0 && this._$Em !== o) {
|
|
201
|
-
const n =
|
|
216
|
+
const n = r.getPropertyOptions(o), l = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((i = n.converter) == null ? void 0 : i.fromAttribute) !== void 0 ? n.converter : V;
|
|
202
217
|
this._$Em = o, this[o] = l.fromAttribute(t, n.type), this._$Em = null;
|
|
203
218
|
}
|
|
204
219
|
}
|
|
205
|
-
requestUpdate(e, t,
|
|
220
|
+
requestUpdate(e, t, r) {
|
|
206
221
|
if (e !== void 0) {
|
|
207
|
-
if (
|
|
208
|
-
this.P(e, t,
|
|
222
|
+
if (r ?? (r = this.constructor.getPropertyOptions(e)), !(r.hasChanged ?? de)(this[e], t)) return;
|
|
223
|
+
this.P(e, t, r);
|
|
209
224
|
}
|
|
210
225
|
this.isUpdatePending === !1 && (this._$ES = this._$ET());
|
|
211
226
|
}
|
|
212
|
-
P(e, t,
|
|
213
|
-
this._$AL.has(e) || this._$AL.set(e, t),
|
|
227
|
+
P(e, t, r) {
|
|
228
|
+
this._$AL.has(e) || this._$AL.set(e, t), r.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e);
|
|
214
229
|
}
|
|
215
230
|
async _$ET() {
|
|
216
231
|
this.isUpdatePending = !0;
|
|
@@ -226,7 +241,7 @@ class P extends HTMLElement {
|
|
|
226
241
|
return this.performUpdate();
|
|
227
242
|
}
|
|
228
243
|
performUpdate() {
|
|
229
|
-
var
|
|
244
|
+
var r;
|
|
230
245
|
if (!this.isUpdatePending) return;
|
|
231
246
|
if (!this.hasUpdated) {
|
|
232
247
|
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
@@ -239,7 +254,7 @@ class P extends HTMLElement {
|
|
|
239
254
|
let e = !1;
|
|
240
255
|
const t = this._$AL;
|
|
241
256
|
try {
|
|
242
|
-
e = this.shouldUpdate(t), e ? (this.willUpdate(t), (
|
|
257
|
+
e = this.shouldUpdate(t), e ? (this.willUpdate(t), (r = this._$EO) == null || r.forEach((o) => {
|
|
243
258
|
var i;
|
|
244
259
|
return (i = o.hostUpdate) == null ? void 0 : i.call(o);
|
|
245
260
|
}), this.update(t)) : this._$EU();
|
|
@@ -252,9 +267,9 @@ class P extends HTMLElement {
|
|
|
252
267
|
}
|
|
253
268
|
_$AE(e) {
|
|
254
269
|
var t;
|
|
255
|
-
(t = this._$EO) == null || t.forEach((
|
|
270
|
+
(t = this._$EO) == null || t.forEach((r) => {
|
|
256
271
|
var o;
|
|
257
|
-
return (o =
|
|
272
|
+
return (o = r.hostUpdated) == null ? void 0 : o.call(r);
|
|
258
273
|
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
|
|
259
274
|
}
|
|
260
275
|
_$EU() {
|
|
@@ -277,49 +292,49 @@ class P extends HTMLElement {
|
|
|
277
292
|
firstUpdated(e) {
|
|
278
293
|
}
|
|
279
294
|
}
|
|
280
|
-
P.elementStyles = [], P.shadowRootOptions = { mode: "open" }, P[U("elementProperties")] = /* @__PURE__ */ new Map(), P[U("finalized")] = /* @__PURE__ */ new Map(), z == null || z({ ReactiveElement: P }), (
|
|
295
|
+
P.elementStyles = [], P.shadowRootOptions = { mode: "open" }, P[U("elementProperties")] = /* @__PURE__ */ new Map(), P[U("finalized")] = /* @__PURE__ */ new Map(), z == null || z({ ReactiveElement: P }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4");
|
|
281
296
|
/**
|
|
282
297
|
* @license
|
|
283
298
|
* Copyright 2017 Google LLC
|
|
284
299
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
285
300
|
*/
|
|
286
|
-
const R = globalThis, M = R.trustedTypes, re = M ? M.createPolicy("lit-html", { createHTML: (
|
|
301
|
+
const R = globalThis, M = R.trustedTypes, re = M ? M.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, he = "$lit$", w = `lit$${Math.random().toFixed(9).slice(2)}$`, ue = "?" + w, Ue = `<${ue}>`, A = document, O = () => A.createComment(""), N = (s) => s === null || typeof s != "object" && typeof s != "function", J = Array.isArray, Re = (s) => J(s) || typeof (s == null ? void 0 : s[Symbol.iterator]) == "function", j = `[
|
|
287
302
|
\f\r]`, T = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, se = /-->/g, oe = />/g, v = RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
|
|
288
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), ie = /'/g, ne = /"/g, pe = /^(?:script|style|textarea|title)$/i,
|
|
289
|
-
function me(
|
|
290
|
-
if (!J(
|
|
303
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), ie = /'/g, ne = /"/g, pe = /^(?:script|style|textarea|title)$/i, Oe = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), c = Oe(1), S = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), ae = /* @__PURE__ */ new WeakMap(), _ = A.createTreeWalker(A, 129);
|
|
304
|
+
function me(s, e) {
|
|
305
|
+
if (!J(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
291
306
|
return re !== void 0 ? re.createHTML(e) : e;
|
|
292
307
|
}
|
|
293
|
-
const
|
|
294
|
-
const t =
|
|
308
|
+
const Ne = (s, e) => {
|
|
309
|
+
const t = s.length - 1, r = [];
|
|
295
310
|
let o, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = T;
|
|
296
311
|
for (let l = 0; l < t; l++) {
|
|
297
|
-
const a =
|
|
312
|
+
const a = s[l];
|
|
298
313
|
let u, d, h = -1, m = 0;
|
|
299
314
|
for (; m < a.length && (n.lastIndex = m, d = n.exec(a), d !== null); ) m = n.lastIndex, n === T ? d[1] === "!--" ? n = se : d[1] !== void 0 ? n = oe : d[2] !== void 0 ? (pe.test(d[2]) && (o = RegExp("</" + d[2], "g")), n = v) : d[3] !== void 0 && (n = v) : n === v ? d[0] === ">" ? (n = o ?? T, h = -1) : d[1] === void 0 ? h = -2 : (h = n.lastIndex - d[2].length, u = d[1], n = d[3] === void 0 ? v : d[3] === '"' ? ne : ie) : n === ne || n === ie ? n = v : n === se || n === oe ? n = T : (n = v, o = void 0);
|
|
300
|
-
const f = n === v &&
|
|
301
|
-
i += n === T ? a +
|
|
315
|
+
const f = n === v && s[l + 1].startsWith("/>") ? " " : "";
|
|
316
|
+
i += n === T ? a + Ue : h >= 0 ? (r.push(u), a.slice(0, h) + he + a.slice(h) + w + f) : a + w + (h === -2 ? l : f);
|
|
302
317
|
}
|
|
303
|
-
return [me(
|
|
318
|
+
return [me(s, i + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
|
|
304
319
|
};
|
|
305
320
|
class H {
|
|
306
|
-
constructor({ strings: e, _$litType$: t },
|
|
321
|
+
constructor({ strings: e, _$litType$: t }, r) {
|
|
307
322
|
let o;
|
|
308
323
|
this.parts = [];
|
|
309
324
|
let i = 0, n = 0;
|
|
310
|
-
const l = e.length - 1, a = this.parts, [u, d] =
|
|
311
|
-
if (this.el = H.createElement(u,
|
|
325
|
+
const l = e.length - 1, a = this.parts, [u, d] = Ne(e, t);
|
|
326
|
+
if (this.el = H.createElement(u, r), _.currentNode = this.el.content, t === 2 || t === 3) {
|
|
312
327
|
const h = this.el.content.firstChild;
|
|
313
328
|
h.replaceWith(...h.childNodes);
|
|
314
329
|
}
|
|
315
330
|
for (; (o = _.nextNode()) !== null && a.length < l; ) {
|
|
316
331
|
if (o.nodeType === 1) {
|
|
317
332
|
if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(he)) {
|
|
318
|
-
const m = d[n++], f = o.getAttribute(h).split(
|
|
319
|
-
a.push({ type: 1, index: i, name: L[2], strings: f, ctor: L[1] === "." ?
|
|
320
|
-
} else h.startsWith(
|
|
333
|
+
const m = d[n++], f = o.getAttribute(h).split(w), L = /([.?@])?(.*)/.exec(m);
|
|
334
|
+
a.push({ type: 1, index: i, name: L[2], strings: f, ctor: L[1] === "." ? qe : L[1] === "?" ? De : L[1] === "@" ? Le : I }), o.removeAttribute(h);
|
|
335
|
+
} else h.startsWith(w) && (a.push({ type: 6, index: i }), o.removeAttribute(h));
|
|
321
336
|
if (pe.test(o.tagName)) {
|
|
322
|
-
const h = o.textContent.split(
|
|
337
|
+
const h = o.textContent.split(w), m = h.length - 1;
|
|
323
338
|
if (m > 0) {
|
|
324
339
|
o.textContent = M ? M.emptyScript : "";
|
|
325
340
|
for (let f = 0; f < m; f++) o.append(h[f], O()), _.nextNode(), a.push({ type: 2, index: ++i });
|
|
@@ -329,24 +344,24 @@ class H {
|
|
|
329
344
|
} else if (o.nodeType === 8) if (o.data === ue) a.push({ type: 2, index: i });
|
|
330
345
|
else {
|
|
331
346
|
let h = -1;
|
|
332
|
-
for (; (h = o.data.indexOf(
|
|
347
|
+
for (; (h = o.data.indexOf(w, h + 1)) !== -1; ) a.push({ type: 7, index: i }), h += w.length - 1;
|
|
333
348
|
}
|
|
334
349
|
i++;
|
|
335
350
|
}
|
|
336
351
|
}
|
|
337
352
|
static createElement(e, t) {
|
|
338
|
-
const
|
|
339
|
-
return
|
|
353
|
+
const r = A.createElement("template");
|
|
354
|
+
return r.innerHTML = e, r;
|
|
340
355
|
}
|
|
341
356
|
}
|
|
342
|
-
function C(
|
|
357
|
+
function C(s, e, t = s, r) {
|
|
343
358
|
var n, l;
|
|
344
359
|
if (e === S) return e;
|
|
345
|
-
let o =
|
|
360
|
+
let o = r !== void 0 ? (n = t._$Co) == null ? void 0 : n[r] : t._$Cl;
|
|
346
361
|
const i = N(e) ? void 0 : e._$litDirective$;
|
|
347
|
-
return (o == null ? void 0 : o.constructor) !== i && ((l = o == null ? void 0 : o._$AO) == null || l.call(o, !1), i === void 0 ? o = void 0 : (o = new i(
|
|
362
|
+
return (o == null ? void 0 : o.constructor) !== i && ((l = o == null ? void 0 : o._$AO) == null || l.call(o, !1), i === void 0 ? o = void 0 : (o = new i(s), o._$AT(s, t, r)), r !== void 0 ? (t._$Co ?? (t._$Co = []))[r] = o : t._$Cl = o), o !== void 0 && (e = C(s, o._$AS(s, e.values), o, r)), e;
|
|
348
363
|
}
|
|
349
|
-
class
|
|
364
|
+
class He {
|
|
350
365
|
constructor(e, t) {
|
|
351
366
|
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
|
|
352
367
|
}
|
|
@@ -357,13 +372,13 @@ class Oe {
|
|
|
357
372
|
return this._$AM._$AU;
|
|
358
373
|
}
|
|
359
374
|
u(e) {
|
|
360
|
-
const { el: { content: t }, parts:
|
|
375
|
+
const { el: { content: t }, parts: r } = this._$AD, o = ((e == null ? void 0 : e.creationScope) ?? A).importNode(t, !0);
|
|
361
376
|
_.currentNode = o;
|
|
362
|
-
let i = _.nextNode(), n = 0, l = 0, a =
|
|
377
|
+
let i = _.nextNode(), n = 0, l = 0, a = r[0];
|
|
363
378
|
for (; a !== void 0; ) {
|
|
364
379
|
if (n === a.index) {
|
|
365
380
|
let u;
|
|
366
|
-
a.type === 2 ? u = new D(i, i.nextSibling, this, e) : a.type === 1 ? u = new a.ctor(i, a.name, a.strings, this, e) : a.type === 6 && (u = new
|
|
381
|
+
a.type === 2 ? u = new D(i, i.nextSibling, this, e) : a.type === 1 ? u = new a.ctor(i, a.name, a.strings, this, e) : a.type === 6 && (u = new Fe(i, this, e)), this._$AV.push(u), a = r[++l];
|
|
367
382
|
}
|
|
368
383
|
n !== (a == null ? void 0 : a.index) && (i = _.nextNode(), n++);
|
|
369
384
|
}
|
|
@@ -371,7 +386,7 @@ class Oe {
|
|
|
371
386
|
}
|
|
372
387
|
p(e) {
|
|
373
388
|
let t = 0;
|
|
374
|
-
for (const
|
|
389
|
+
for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(e, r, t), t += r.strings.length - 2) : r._$AI(e[t])), t++;
|
|
375
390
|
}
|
|
376
391
|
}
|
|
377
392
|
class D {
|
|
@@ -379,8 +394,8 @@ class D {
|
|
|
379
394
|
var e;
|
|
380
395
|
return ((e = this._$AM) == null ? void 0 : e._$AU) ?? this._$Cv;
|
|
381
396
|
}
|
|
382
|
-
constructor(e, t,
|
|
383
|
-
this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM =
|
|
397
|
+
constructor(e, t, r, o) {
|
|
398
|
+
this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = o, this._$Cv = (o == null ? void 0 : o.isConnected) ?? !0;
|
|
384
399
|
}
|
|
385
400
|
get parentNode() {
|
|
386
401
|
let e = this._$AA.parentNode;
|
|
@@ -394,7 +409,7 @@ class D {
|
|
|
394
409
|
return this._$AB;
|
|
395
410
|
}
|
|
396
411
|
_$AI(e, t = this) {
|
|
397
|
-
e = C(this, e, t), N(e) ? e === p || e == null || e === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : e !== this._$AH && e !== S && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) :
|
|
412
|
+
e = C(this, e, t), N(e) ? e === p || e == null || e === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : e !== this._$AH && e !== S && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Re(e) ? this.k(e) : this._(e);
|
|
398
413
|
}
|
|
399
414
|
O(e) {
|
|
400
415
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -407,10 +422,10 @@ class D {
|
|
|
407
422
|
}
|
|
408
423
|
$(e) {
|
|
409
424
|
var i;
|
|
410
|
-
const { values: t, _$litType$:
|
|
425
|
+
const { values: t, _$litType$: r } = e, o = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = H.createElement(me(r.h, r.h[0]), this.options)), r);
|
|
411
426
|
if (((i = this._$AH) == null ? void 0 : i._$AD) === o) this._$AH.p(t);
|
|
412
427
|
else {
|
|
413
|
-
const n = new
|
|
428
|
+
const n = new He(o, this), l = n.u(this.options);
|
|
414
429
|
n.p(t), this.T(l), this._$AH = n;
|
|
415
430
|
}
|
|
416
431
|
}
|
|
@@ -421,13 +436,13 @@ class D {
|
|
|
421
436
|
k(e) {
|
|
422
437
|
J(this._$AH) || (this._$AH = [], this._$AR());
|
|
423
438
|
const t = this._$AH;
|
|
424
|
-
let
|
|
425
|
-
for (const i of e) o === t.length ? t.push(
|
|
426
|
-
o < t.length && (this._$AR(
|
|
439
|
+
let r, o = 0;
|
|
440
|
+
for (const i of e) o === t.length ? t.push(r = new D(this.O(O()), this.O(O()), this, this.options)) : r = t[o], r._$AI(i), o++;
|
|
441
|
+
o < t.length && (this._$AR(r && r._$AB.nextSibling, o), t.length = o);
|
|
427
442
|
}
|
|
428
443
|
_$AR(e = this._$AA.nextSibling, t) {
|
|
429
|
-
var
|
|
430
|
-
for ((
|
|
444
|
+
var r;
|
|
445
|
+
for ((r = this._$AP) == null ? void 0 : r.call(this, !1, !0, t); e && e !== this._$AB; ) {
|
|
431
446
|
const o = e.nextSibling;
|
|
432
447
|
e.remove(), e = o;
|
|
433
448
|
}
|
|
@@ -444,17 +459,17 @@ class I {
|
|
|
444
459
|
get _$AU() {
|
|
445
460
|
return this._$AM._$AU;
|
|
446
461
|
}
|
|
447
|
-
constructor(e, t,
|
|
448
|
-
this.type = 1, this._$AH = p, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = i,
|
|
462
|
+
constructor(e, t, r, o, i) {
|
|
463
|
+
this.type = 1, this._$AH = p, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = p;
|
|
449
464
|
}
|
|
450
|
-
_$AI(e, t = this,
|
|
465
|
+
_$AI(e, t = this, r, o) {
|
|
451
466
|
const i = this.strings;
|
|
452
467
|
let n = !1;
|
|
453
468
|
if (i === void 0) e = C(this, e, t, 0), n = !N(e) || e !== this._$AH && e !== S, n && (this._$AH = e);
|
|
454
469
|
else {
|
|
455
470
|
const l = e;
|
|
456
471
|
let a, u;
|
|
457
|
-
for (e = i[0], a = 0; a < i.length - 1; a++) u = C(this, l[
|
|
472
|
+
for (e = i[0], a = 0; a < i.length - 1; a++) u = C(this, l[r + a], t, a), u === S && (u = this._$AH[a]), n || (n = !N(u) || u !== this._$AH[a]), u === p ? e = p : e !== p && (e += (u ?? "") + i[a + 1]), this._$AH[a] = u;
|
|
458
473
|
}
|
|
459
474
|
n && !o && this.j(e);
|
|
460
475
|
}
|
|
@@ -462,7 +477,7 @@ class I {
|
|
|
462
477
|
e === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
463
478
|
}
|
|
464
479
|
}
|
|
465
|
-
class
|
|
480
|
+
class qe extends I {
|
|
466
481
|
constructor() {
|
|
467
482
|
super(...arguments), this.type = 3;
|
|
468
483
|
}
|
|
@@ -470,7 +485,7 @@ class Ne extends I {
|
|
|
470
485
|
this.element[this.name] = e === p ? void 0 : e;
|
|
471
486
|
}
|
|
472
487
|
}
|
|
473
|
-
class
|
|
488
|
+
class De extends I {
|
|
474
489
|
constructor() {
|
|
475
490
|
super(...arguments), this.type = 4;
|
|
476
491
|
}
|
|
@@ -478,23 +493,23 @@ class He extends I {
|
|
|
478
493
|
this.element.toggleAttribute(this.name, !!e && e !== p);
|
|
479
494
|
}
|
|
480
495
|
}
|
|
481
|
-
class
|
|
482
|
-
constructor(e, t,
|
|
483
|
-
super(e, t,
|
|
496
|
+
class Le extends I {
|
|
497
|
+
constructor(e, t, r, o, i) {
|
|
498
|
+
super(e, t, r, o, i), this.type = 5;
|
|
484
499
|
}
|
|
485
500
|
_$AI(e, t = this) {
|
|
486
501
|
if ((e = C(this, e, t, 0) ?? p) === S) return;
|
|
487
|
-
const
|
|
488
|
-
o && this.element.removeEventListener(this.name, this,
|
|
502
|
+
const r = this._$AH, o = e === p && r !== p || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, i = e !== p && (r === p || o);
|
|
503
|
+
o && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
489
504
|
}
|
|
490
505
|
handleEvent(e) {
|
|
491
506
|
var t;
|
|
492
507
|
typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e);
|
|
493
508
|
}
|
|
494
509
|
}
|
|
495
|
-
class
|
|
496
|
-
constructor(e, t,
|
|
497
|
-
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options =
|
|
510
|
+
class Fe {
|
|
511
|
+
constructor(e, t, r) {
|
|
512
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
|
|
498
513
|
}
|
|
499
514
|
get _$AU() {
|
|
500
515
|
return this._$AM._$AU;
|
|
@@ -505,14 +520,14 @@ class De {
|
|
|
505
520
|
}
|
|
506
521
|
const W = R.litHtmlPolyfillSupport;
|
|
507
522
|
W == null || W(H, D), (R.litHtmlVersions ?? (R.litHtmlVersions = [])).push("3.2.1");
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
-
let o =
|
|
523
|
+
const Me = (s, e, t) => {
|
|
524
|
+
const r = (t == null ? void 0 : t.renderBefore) ?? e;
|
|
525
|
+
let o = r._$litPart$;
|
|
511
526
|
if (o === void 0) {
|
|
512
527
|
const i = (t == null ? void 0 : t.renderBefore) ?? null;
|
|
513
|
-
|
|
528
|
+
r._$litPart$ = o = new D(e.insertBefore(O(), i), i, void 0, t ?? {});
|
|
514
529
|
}
|
|
515
|
-
return o._$AI(
|
|
530
|
+
return o._$AI(s), o;
|
|
516
531
|
};
|
|
517
532
|
/**
|
|
518
533
|
* @license
|
|
@@ -530,7 +545,7 @@ class b extends P {
|
|
|
530
545
|
}
|
|
531
546
|
update(e) {
|
|
532
547
|
const t = this.render();
|
|
533
|
-
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do =
|
|
548
|
+
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = Me(t, this.renderRoot, this.renderOptions);
|
|
534
549
|
}
|
|
535
550
|
connectedCallback() {
|
|
536
551
|
var e;
|
|
@@ -549,20 +564,20 @@ b._$litElement$ = !0, b.finalized = !0, (le = globalThis.litElementHydrateSuppor
|
|
|
549
564
|
const B = globalThis.litElementPolyfillSupport;
|
|
550
565
|
B == null || B({ LitElement: b });
|
|
551
566
|
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
|
|
552
|
-
function x(
|
|
567
|
+
function x(s) {
|
|
553
568
|
return {
|
|
554
569
|
// Underlying mechanism to use the REST URLs directly.
|
|
555
|
-
api: (e, t) => E(
|
|
556
|
-
mintToken: ({ username: e, password: t }) =>
|
|
557
|
-
refreshToken: ({ token: e }) =>
|
|
558
|
-
pubkey: () =>
|
|
559
|
-
updatePassword: ({ token: e, currentPassword: t, newPassword:
|
|
560
|
-
triggerResetPassword: ({ username: e }) =>
|
|
561
|
-
confirmResetPassword: ({ username: e, newPassword: t, confirmationCode:
|
|
570
|
+
api: (e, t) => E(s, e, t),
|
|
571
|
+
mintToken: ({ username: e, password: t }) => Ie({ config: s, username: e, password: t }),
|
|
572
|
+
refreshToken: ({ token: e }) => ze({ config: s, token: e }),
|
|
573
|
+
pubkey: () => je({ config: s }),
|
|
574
|
+
updatePassword: ({ token: e, currentPassword: t, newPassword: r }) => We({ config: s, token: e, currentPassword: t, newPassword: r }),
|
|
575
|
+
triggerResetPassword: ({ username: e }) => Be({ config: s, username: e }),
|
|
576
|
+
confirmResetPassword: ({ username: e, newPassword: t, confirmationCode: r }) => Ge({ config: s, username: e, newPassword: t, confirmationCode: r })
|
|
562
577
|
};
|
|
563
578
|
}
|
|
564
|
-
function
|
|
565
|
-
return E(
|
|
579
|
+
function Ie({ config: s, username: e, password: t }) {
|
|
580
|
+
return E(s, "/v1/user/login", {
|
|
566
581
|
method: "POST",
|
|
567
582
|
body: {
|
|
568
583
|
username: e,
|
|
@@ -570,52 +585,52 @@ function Fe({ config: r, username: e, password: t }) {
|
|
|
570
585
|
}
|
|
571
586
|
});
|
|
572
587
|
}
|
|
573
|
-
function
|
|
574
|
-
return E(
|
|
588
|
+
function ze({ config: s, token: e }) {
|
|
589
|
+
return E(s, "/v1/refresh", {
|
|
575
590
|
method: "POST",
|
|
576
591
|
body: {
|
|
577
592
|
token: e
|
|
578
593
|
}
|
|
579
594
|
});
|
|
580
595
|
}
|
|
581
|
-
function
|
|
582
|
-
return E(
|
|
596
|
+
function je({ config: s }) {
|
|
597
|
+
return E(s, "/v1/pubkey", {
|
|
583
598
|
method: "GET"
|
|
584
599
|
});
|
|
585
600
|
}
|
|
586
|
-
function
|
|
587
|
-
return E(
|
|
601
|
+
function We({ config: s, token: e, currentPassword: t, newPassword: r }) {
|
|
602
|
+
return E(s, "/v1/user/password", {
|
|
588
603
|
method: "PUT",
|
|
589
604
|
body: {
|
|
590
605
|
currentPassword: t,
|
|
591
|
-
newPassword:
|
|
606
|
+
newPassword: r
|
|
592
607
|
},
|
|
593
608
|
headers: {
|
|
594
609
|
Authorization: `Bearer ${e}`
|
|
595
610
|
}
|
|
596
611
|
});
|
|
597
612
|
}
|
|
598
|
-
function
|
|
599
|
-
return E(
|
|
613
|
+
function Be({ config: s, username: e }) {
|
|
614
|
+
return E(s, "/v1/user/password/reset", {
|
|
600
615
|
method: "POST",
|
|
601
616
|
body: {
|
|
602
617
|
username: e
|
|
603
618
|
}
|
|
604
619
|
});
|
|
605
620
|
}
|
|
606
|
-
function
|
|
607
|
-
return E(
|
|
621
|
+
function Ge({ config: s, username: e, newPassword: t, confirmationCode: r }) {
|
|
622
|
+
return E(s, "/v1/user/password/reset/confirm", {
|
|
608
623
|
method: "POST",
|
|
609
624
|
body: {
|
|
610
625
|
username: e,
|
|
611
626
|
newPassword: t,
|
|
612
|
-
confirmationCode:
|
|
627
|
+
confirmationCode: r
|
|
613
628
|
}
|
|
614
629
|
});
|
|
615
630
|
}
|
|
616
|
-
async function E(
|
|
631
|
+
async function E(s, e, t) {
|
|
617
632
|
var u;
|
|
618
|
-
const
|
|
633
|
+
const r = s.baseUrl.endsWith("/") ? s.baseUrl : `${s.baseUrl}/`, o = e.startsWith("/") ? e.substring(1) : e, i = new URL(o, r), l = Object.assign({}, t, {
|
|
619
634
|
headers: Object.assign({}, {
|
|
620
635
|
"Content-Type": "application/json"
|
|
621
636
|
}, t == null ? void 0 : t.headers),
|
|
@@ -634,18 +649,18 @@ async function E(r, e, t) {
|
|
|
634
649
|
if (a.status !== 204)
|
|
635
650
|
return await a.json();
|
|
636
651
|
}
|
|
637
|
-
function fe({ api:
|
|
652
|
+
function fe({ api: s }, e) {
|
|
638
653
|
const t = x({
|
|
639
|
-
baseUrl:
|
|
654
|
+
baseUrl: s
|
|
640
655
|
});
|
|
641
|
-
return console.log("sending credentials to API",
|
|
656
|
+
return console.log("sending credentials to API", s), t.mintToken(e);
|
|
642
657
|
}
|
|
643
658
|
const g = Object.freeze({
|
|
644
659
|
REQUEST: "request",
|
|
645
660
|
CONFIRM: "confirm",
|
|
646
661
|
FINISHED: "finished"
|
|
647
662
|
});
|
|
648
|
-
class
|
|
663
|
+
class Ve extends b {
|
|
649
664
|
static get properties() {
|
|
650
665
|
return {
|
|
651
666
|
api: { type: String, attribute: "api" },
|
|
@@ -713,8 +728,8 @@ class Be extends b {
|
|
|
713
728
|
}
|
|
714
729
|
handleSubmitConfirm(e) {
|
|
715
730
|
e.preventDefault();
|
|
716
|
-
const t = e.target.password.value,
|
|
717
|
-
if (t !==
|
|
731
|
+
const t = e.target.password.value, r = e.target["confirm-password"].value;
|
|
732
|
+
if (t !== r) {
|
|
718
733
|
this.errors["confirm-password"] = "Passwords do not match.", this.requestUpdate();
|
|
719
734
|
return;
|
|
720
735
|
}
|
|
@@ -896,10 +911,10 @@ class y extends b {
|
|
|
896
911
|
e.preventDefault();
|
|
897
912
|
const t = e.explicitOriginalTarget.parentElement;
|
|
898
913
|
console.log(t);
|
|
899
|
-
const
|
|
900
|
-
fe(this,
|
|
914
|
+
const r = new FormData(t).entries().reduce((o, [i, n]) => (o[i] = n, o), {});
|
|
915
|
+
fe(this, r).then(({ token: o, challenge: i }) => {
|
|
901
916
|
if (i && i.name === "NEW_PASSWORD_REQUIRED") {
|
|
902
|
-
this.token = o, this.username =
|
|
917
|
+
this.token = o, this.username = r.username, this.password = r.password, this.setState(y.states.CHALLENGE_CHANGE_PW);
|
|
903
918
|
return;
|
|
904
919
|
}
|
|
905
920
|
this.dispatchEvent(new CustomEvent("login-success", {
|
|
@@ -911,7 +926,7 @@ class y extends b {
|
|
|
911
926
|
}
|
|
912
927
|
onSubmitChangePasswordChallenge(e) {
|
|
913
928
|
e.preventDefault();
|
|
914
|
-
const t = e.explicitOriginalTarget,
|
|
929
|
+
const t = e.explicitOriginalTarget, r = new FormData(t).entries().reduce((l, [a, u]) => (l[a] = u, l), {}), o = r.password, i = r["confirm-password"];
|
|
915
930
|
if (o !== i) {
|
|
916
931
|
this.errors = ["Passwords do not match."], this.requestUpdate();
|
|
917
932
|
return;
|
|
@@ -1018,9 +1033,9 @@ class y extends b {
|
|
|
1018
1033
|
}
|
|
1019
1034
|
}
|
|
1020
1035
|
customElements.define("auth-login-form", y);
|
|
1021
|
-
customElements.define("auth-forgot-password-form",
|
|
1022
|
-
function
|
|
1023
|
-
return function(
|
|
1036
|
+
customElements.define("auth-forgot-password-form", Ve);
|
|
1037
|
+
function Ke() {
|
|
1038
|
+
return function(s) {
|
|
1024
1039
|
const e = q`
|
|
1025
1040
|
.login-layout {
|
|
1026
1041
|
display: flex;
|
|
@@ -1038,36 +1053,36 @@ function Ge() {
|
|
|
1038
1053
|
return c`
|
|
1039
1054
|
<style>${e}</style>
|
|
1040
1055
|
<div class="login-layout">
|
|
1041
|
-
${
|
|
1056
|
+
${s.main}
|
|
1042
1057
|
</div>
|
|
1043
1058
|
`;
|
|
1044
1059
|
};
|
|
1045
1060
|
}
|
|
1046
|
-
function
|
|
1047
|
-
return JSON.parse(window.atob(
|
|
1061
|
+
function Qe(s) {
|
|
1062
|
+
return JSON.parse(window.atob(s.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
1048
1063
|
}
|
|
1049
|
-
function
|
|
1050
|
-
return
|
|
1064
|
+
function Je(s, e = 300, t = Date.now()) {
|
|
1065
|
+
return Qe(s).exp * 1e3 - e < t;
|
|
1051
1066
|
}
|
|
1052
|
-
function ge(
|
|
1053
|
-
return (
|
|
1067
|
+
function ge(s) {
|
|
1068
|
+
return (s.startsWith("/") ? s : `/${s}`).replace(/\/{2,}/g, "/").replace(new RegExp("(?<=.)\\/$"), "");
|
|
1054
1069
|
}
|
|
1055
|
-
function ye(
|
|
1056
|
-
const
|
|
1057
|
-
e.pushState(t, t.title,
|
|
1070
|
+
function ye(s, e, t) {
|
|
1071
|
+
const r = Ze(s, t);
|
|
1072
|
+
e.pushState(t, t.title, r), s.requestRender(t);
|
|
1058
1073
|
}
|
|
1059
|
-
function
|
|
1060
|
-
const { mount: t } =
|
|
1074
|
+
function Ye(s, e) {
|
|
1075
|
+
const { mount: t } = s.config, { history: r } = s.config.toolkit.element.ownerDocument.defaultView;
|
|
1061
1076
|
return e.startsWith(t) ? {
|
|
1062
1077
|
path: ge(e.slice(t.length)),
|
|
1063
|
-
push: (o) => ye(
|
|
1078
|
+
push: (o) => ye(s, r, o)
|
|
1064
1079
|
} : null;
|
|
1065
1080
|
}
|
|
1066
|
-
function
|
|
1067
|
-
const { mount: t } =
|
|
1081
|
+
function Ze(s, e) {
|
|
1082
|
+
const { mount: t } = s.config;
|
|
1068
1083
|
return ge(`${t}/${e.path}`);
|
|
1069
1084
|
}
|
|
1070
|
-
function
|
|
1085
|
+
function Xe(s, e) {
|
|
1071
1086
|
const { history: t } = e.config.toolkit.element.ownerDocument.defaultView;
|
|
1072
1087
|
return c`
|
|
1073
1088
|
<h1>Auth Dashboard</h1>
|
|
@@ -1079,12 +1094,12 @@ function Ye(r, e) {
|
|
|
1079
1094
|
</ul>
|
|
1080
1095
|
`;
|
|
1081
1096
|
}
|
|
1082
|
-
function
|
|
1097
|
+
function et(s, e) {
|
|
1083
1098
|
return c`
|
|
1084
1099
|
<auth-change-password-form .auth=${e}></auth-change-password-form>
|
|
1085
1100
|
`;
|
|
1086
1101
|
}
|
|
1087
|
-
class
|
|
1102
|
+
class tt extends b {
|
|
1088
1103
|
static get styles() {
|
|
1089
1104
|
return q`
|
|
1090
1105
|
:host {
|
|
@@ -1132,7 +1147,7 @@ class Xe extends b {
|
|
|
1132
1147
|
super(), this.errors = {}, this.success = null;
|
|
1133
1148
|
}
|
|
1134
1149
|
connectedCallback() {
|
|
1135
|
-
super.connectedCallback(),
|
|
1150
|
+
super.connectedCallback(), G(this);
|
|
1136
1151
|
}
|
|
1137
1152
|
async onSubmit(e) {
|
|
1138
1153
|
if (e.preventDefault(), e.target.newPassword.value !== e.target.confirmPassword.value) {
|
|
@@ -1143,15 +1158,15 @@ class Xe extends b {
|
|
|
1143
1158
|
this.errors.newPassword = "The new password is the same as your current password.", this.requestUpdate();
|
|
1144
1159
|
return;
|
|
1145
1160
|
}
|
|
1146
|
-
await
|
|
1161
|
+
await G(this), await x({
|
|
1147
1162
|
baseUrl: this.auth.config.api
|
|
1148
1163
|
}).updatePassword({
|
|
1149
1164
|
currentPassword: e.target.currentPassword.value,
|
|
1150
1165
|
newPassword: e.target.newPassword.value
|
|
1151
1166
|
}).then(() => {
|
|
1152
1167
|
this.errors = {}, this.success = "Password changed.", this.requestUpdate();
|
|
1153
|
-
}).catch((
|
|
1154
|
-
this.errors.submit =
|
|
1168
|
+
}).catch((r) => {
|
|
1169
|
+
this.errors.submit = r.message, this.requestUpdate();
|
|
1155
1170
|
});
|
|
1156
1171
|
}
|
|
1157
1172
|
render() {
|
|
@@ -1196,24 +1211,24 @@ class Xe extends b {
|
|
|
1196
1211
|
`;
|
|
1197
1212
|
}
|
|
1198
1213
|
}
|
|
1199
|
-
customElements.get("auth-change-password-form") || customElements.define("auth-change-password-form",
|
|
1200
|
-
const
|
|
1201
|
-
{ path: "/", render:
|
|
1202
|
-
{ path: "/change-password", render:
|
|
1214
|
+
customElements.get("auth-change-password-form") || customElements.define("auth-change-password-form", tt);
|
|
1215
|
+
const rt = [
|
|
1216
|
+
{ path: "/", render: Xe },
|
|
1217
|
+
{ path: "/change-password", render: et }
|
|
1203
1218
|
];
|
|
1204
|
-
function
|
|
1205
|
-
const { path: t } =
|
|
1206
|
-
if (
|
|
1207
|
-
return
|
|
1219
|
+
function st(s, e) {
|
|
1220
|
+
const { path: t } = s, r = rt.find((o) => o.path === t);
|
|
1221
|
+
if (r)
|
|
1222
|
+
return r.render(s, e);
|
|
1208
1223
|
}
|
|
1209
|
-
const
|
|
1224
|
+
const ot = q`
|
|
1210
1225
|
:host {
|
|
1211
1226
|
|
|
1212
1227
|
}
|
|
1213
1228
|
`;
|
|
1214
|
-
class
|
|
1229
|
+
class it extends b {
|
|
1215
1230
|
static get styles() {
|
|
1216
|
-
return [
|
|
1231
|
+
return [ot];
|
|
1217
1232
|
}
|
|
1218
1233
|
static get properties() {
|
|
1219
1234
|
return {
|
|
@@ -1223,25 +1238,25 @@ class st extends b {
|
|
|
1223
1238
|
}
|
|
1224
1239
|
render() {
|
|
1225
1240
|
const { state: e, auth: t } = this;
|
|
1226
|
-
return
|
|
1241
|
+
return st(e, t);
|
|
1227
1242
|
}
|
|
1228
1243
|
}
|
|
1229
|
-
customElements.get("auth-app") || customElements.define("auth-app",
|
|
1230
|
-
function
|
|
1244
|
+
customElements.get("auth-app") || customElements.define("auth-app", it);
|
|
1245
|
+
function nt(s) {
|
|
1231
1246
|
const e = {
|
|
1232
|
-
config:
|
|
1247
|
+
config: s,
|
|
1233
1248
|
log: (...t) => console.log("[auth]", ...t)
|
|
1234
1249
|
};
|
|
1235
|
-
return e.mount = k(
|
|
1250
|
+
return e.mount = k(at, e), e.handleTokenRequest = ct(e), e.handleDestroyAuth = dt(e), e.presentLoginForm = k(ht, e), e.getToken = k($e, e), e.saveToken = k(ut, e), e.getFreshToken = k(pt, e), e.requestRender = (t) => we(e, t), e;
|
|
1236
1251
|
}
|
|
1237
|
-
function
|
|
1238
|
-
const e =
|
|
1252
|
+
function at(s) {
|
|
1253
|
+
const e = s.config.toolkit.element.ownerDocument.defaultView;
|
|
1239
1254
|
[
|
|
1240
1255
|
{
|
|
1241
1256
|
type: "action:register",
|
|
1242
1257
|
detail: {
|
|
1243
1258
|
actionType: "auth:requestToken",
|
|
1244
|
-
handler:
|
|
1259
|
+
handler: s.handleTokenRequest,
|
|
1245
1260
|
modName: "auth"
|
|
1246
1261
|
}
|
|
1247
1262
|
},
|
|
@@ -1249,7 +1264,7 @@ function ot(r) {
|
|
|
1249
1264
|
type: "action:register",
|
|
1250
1265
|
detail: {
|
|
1251
1266
|
actionType: "auth:destroy",
|
|
1252
|
-
handler:
|
|
1267
|
+
handler: s.handleDestroyAuth,
|
|
1253
1268
|
modName: "auth"
|
|
1254
1269
|
}
|
|
1255
1270
|
},
|
|
@@ -1258,31 +1273,31 @@ function ot(r) {
|
|
|
1258
1273
|
detail: {
|
|
1259
1274
|
name: "auth:login",
|
|
1260
1275
|
slots: ["main"],
|
|
1261
|
-
templateFn:
|
|
1276
|
+
templateFn: Ke()
|
|
1262
1277
|
}
|
|
1263
1278
|
}
|
|
1264
|
-
].forEach((t) =>
|
|
1279
|
+
].forEach((t) => s.config.toolkit.dispatchAction(t)), e.addEventListener("popstate", lt(s));
|
|
1265
1280
|
}
|
|
1266
|
-
function
|
|
1267
|
-
const t =
|
|
1268
|
-
let
|
|
1269
|
-
|
|
1281
|
+
function we(s, e) {
|
|
1282
|
+
const t = s.config.toolkit.element.ownerDocument.defaultView;
|
|
1283
|
+
let r = e;
|
|
1284
|
+
r || (r = Ye(s, t.location.pathname)), r && s.config.toolkit.dispatchAction({
|
|
1270
1285
|
type: "layout:slot:replace",
|
|
1271
1286
|
detail: {
|
|
1272
1287
|
layout: "menu-main-task-layout",
|
|
1273
1288
|
slot: "main",
|
|
1274
|
-
content: c`<auth-app .state=${
|
|
1289
|
+
content: c`<auth-app .state=${r} .auth=${s}></auth-app>`
|
|
1275
1290
|
}
|
|
1276
1291
|
});
|
|
1277
1292
|
}
|
|
1278
|
-
function
|
|
1293
|
+
function lt(s) {
|
|
1279
1294
|
return (e) => {
|
|
1280
|
-
|
|
1295
|
+
s.log("onpopstate", e), we(s);
|
|
1281
1296
|
};
|
|
1282
1297
|
}
|
|
1283
|
-
function
|
|
1298
|
+
function ct(s) {
|
|
1284
1299
|
let e = [], t = !1;
|
|
1285
|
-
const
|
|
1300
|
+
const r = (o) => {
|
|
1286
1301
|
e.forEach((i) => {
|
|
1287
1302
|
i(o);
|
|
1288
1303
|
}), e = [];
|
|
@@ -1290,29 +1305,29 @@ function nt(r) {
|
|
|
1290
1305
|
return async ({ callback: o }) => {
|
|
1291
1306
|
let i;
|
|
1292
1307
|
try {
|
|
1293
|
-
i = await
|
|
1308
|
+
i = await s.getFreshToken(), o(i);
|
|
1294
1309
|
} catch (n) {
|
|
1295
|
-
e.push(o), t || (
|
|
1310
|
+
e.push(o), t || (s.presentLoginForm({ onLogin: r }), t = !0), s.log(n);
|
|
1296
1311
|
}
|
|
1297
1312
|
};
|
|
1298
1313
|
}
|
|
1299
|
-
function
|
|
1314
|
+
function dt(s) {
|
|
1300
1315
|
return () => {
|
|
1301
|
-
const e =
|
|
1302
|
-
window.localStorage.removeItem(e),
|
|
1316
|
+
const e = Y(s);
|
|
1317
|
+
window.localStorage.removeItem(e), s.config.toolkit.dispatchAction({
|
|
1303
1318
|
type: "layout:pop"
|
|
1304
1319
|
});
|
|
1305
1320
|
};
|
|
1306
1321
|
}
|
|
1307
|
-
function
|
|
1308
|
-
const { toolkit: t } =
|
|
1322
|
+
function ht(s, { onLogin: e }) {
|
|
1323
|
+
const { toolkit: t } = s.config, o = new URLSearchParams(
|
|
1309
1324
|
t.element.ownerDocument.defaultView.location.search
|
|
1310
1325
|
).get("password_reset_confirmation"), i = (n) => {
|
|
1311
|
-
|
|
1326
|
+
s.log("login success", { event: n });
|
|
1312
1327
|
const { token: l } = n.detail;
|
|
1313
|
-
|
|
1328
|
+
s.log("Login form dismissed", { args: [l] }), t.dispatchAction({
|
|
1314
1329
|
type: "layout:pop"
|
|
1315
|
-
}),
|
|
1330
|
+
}), s.saveToken({ token: l }), e({ token: l });
|
|
1316
1331
|
};
|
|
1317
1332
|
t.dispatchAction({
|
|
1318
1333
|
type: "layout:push",
|
|
@@ -1325,43 +1340,39 @@ function lt(r, { onLogin: e }) {
|
|
|
1325
1340
|
layout: "auth:login",
|
|
1326
1341
|
slot: "main",
|
|
1327
1342
|
content: c`<auth-login-form
|
|
1328
|
-
api=${
|
|
1343
|
+
api=${s.config.api}
|
|
1329
1344
|
confirmation="${o}"
|
|
1330
1345
|
@login-success=${i}>
|
|
1331
1346
|
</auth-login-form>`
|
|
1332
1347
|
}
|
|
1333
1348
|
});
|
|
1334
1349
|
}
|
|
1335
|
-
function
|
|
1336
|
-
|
|
1337
|
-
const t =
|
|
1350
|
+
function ut(s, { token: e }) {
|
|
1351
|
+
s.log("saving token", { args: [e] });
|
|
1352
|
+
const t = Y(s);
|
|
1338
1353
|
window.localStorage.setItem(t, e);
|
|
1339
1354
|
}
|
|
1340
|
-
function
|
|
1341
|
-
const e =
|
|
1355
|
+
function $e(s) {
|
|
1356
|
+
const e = Y(s);
|
|
1342
1357
|
return window.localStorage.getItem(e);
|
|
1343
1358
|
}
|
|
1344
|
-
async function
|
|
1345
|
-
const e =
|
|
1359
|
+
async function pt(s) {
|
|
1360
|
+
const e = $e(s);
|
|
1346
1361
|
if (!e || e.length < 1)
|
|
1347
1362
|
throw new Error("No token found");
|
|
1348
|
-
return
|
|
1349
|
-
baseUrl:
|
|
1350
|
-
}).refreshToken({ token: e }).then(({ token:
|
|
1363
|
+
return Je(e) ? (s.log("refreshing token", { args: [e] }), await x({
|
|
1364
|
+
baseUrl: s.config.api
|
|
1365
|
+
}).refreshToken({ token: e }).then(({ token: r }) => r)) : e;
|
|
1366
|
+
}
|
|
1367
|
+
function Y({ storageKey: s = "token" }) {
|
|
1368
|
+
return s;
|
|
1351
1369
|
}
|
|
1352
|
-
function
|
|
1353
|
-
|
|
1370
|
+
function gt(s, e) {
|
|
1371
|
+
const t = be(s, e), r = nt(t);
|
|
1372
|
+
r.mount(), r.requestRender(), t.forceLogin && G(s.element).then((o) => {
|
|
1373
|
+
r.log("You have logged in successfully!", o);
|
|
1374
|
+
});
|
|
1354
1375
|
}
|
|
1355
1376
|
export {
|
|
1356
|
-
|
|
1357
|
-
we as getToken,
|
|
1358
|
-
K as getTokenStorageKey,
|
|
1359
|
-
it as historyStateHandler,
|
|
1360
|
-
at as loginDestroyHandler,
|
|
1361
|
-
pt as makeAuth,
|
|
1362
|
-
ot as mount,
|
|
1363
|
-
lt as presentLoginForm,
|
|
1364
|
-
$e as renderApp,
|
|
1365
|
-
ct as saveToken,
|
|
1366
|
-
nt as tokenRequestHandler
|
|
1377
|
+
gt as init
|
|
1367
1378
|
};
|