@wral/studio.mods.auth 1.0.1 → 2.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/README.md +3 -3
- package/dist/auth.cjs.js +119 -205
- package/dist/auth.es.js +466 -696
- package/dist/lib.cjs.js +1 -1
- package/dist/lib.es.js +4 -6
- package/example-app.mjs +34 -0
- package/index.html +19 -72
- package/package.json +3 -2
- package/src/{components/forgot-password-form.mjs → forgot-password-form.mjs} +69 -69
- package/src/helper.mjs +5 -16
- package/src/index.mjs +108 -12
- package/src/layout.mjs +38 -0
- package/src/{components/login-form.mjs → login-form.mjs} +125 -122
- package/src/token.mjs +34 -30
- package/vellum/README.md +1 -0
- package/vellum/app-manager.mjs +126 -0
- package/vellum/example-app.mjs +34 -0
- package/vellum/index.mjs +26 -0
- package/vellum/layout.mjs +85 -0
- package/vellum/mod-setup.mjs +22 -0
- package/vellum/render.mjs +21 -0
- package/vellum/themes/default/index.css +89 -0
- package/src/auth.mjs +0 -208
- package/src/auth.test.mjs +0 -97
- package/src/components/auth-app.mjs +0 -26
- package/src/config.mjs +0 -27
- package/src/login-layout.mjs +0 -32
- package/src/login.mjs +0 -20
- package/src/routes/change-password.mjs +0 -158
- package/src/routes/dashboard.mjs +0 -17
- package/src/routes/index.mjs +0 -15
- package/src/state.mjs +0 -61
- package/src/state.test.mjs +0 -58
- package/src/styles.mjs +0 -9
- package/src/utils.mjs +0 -3
- package/vellum-fixture.mjs +0 -86
package/dist/auth.es.js
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
import { getToken as
|
|
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);
|
|
19
|
-
}
|
|
1
|
+
import { getToken as fe } from "./lib.es.js";
|
|
20
2
|
/**
|
|
21
3
|
* @license
|
|
22
4
|
* Copyright 2019 Google LLC
|
|
23
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
24
6
|
*/
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
constructor(e, t,
|
|
28
|
-
if (this._$cssResult$ = !0,
|
|
7
|
+
const q = globalThis, G = q.ShadowRoot && (q.ShadyCSS === void 0 || q.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, V = Symbol(), K = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
let ae = class {
|
|
9
|
+
constructor(e, t, s) {
|
|
10
|
+
if (this._$cssResult$ = !0, s !== V) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
29
11
|
this.cssText = e, this.t = t;
|
|
30
12
|
}
|
|
31
13
|
get styleSheet() {
|
|
32
14
|
let e = this.o;
|
|
33
15
|
const t = this.t;
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
16
|
+
if (G && e === void 0) {
|
|
17
|
+
const s = t !== void 0 && t.length === 1;
|
|
18
|
+
s && (e = K.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), s && K.set(t, e));
|
|
37
19
|
}
|
|
38
20
|
return e;
|
|
39
21
|
}
|
|
@@ -41,74 +23,74 @@ let ce = class {
|
|
|
41
23
|
return this.cssText;
|
|
42
24
|
}
|
|
43
25
|
};
|
|
44
|
-
const
|
|
45
|
-
const t =
|
|
26
|
+
const ge = (r) => new ae(typeof r == "string" ? r : r + "", void 0, V), J = (r, ...e) => {
|
|
27
|
+
const t = r.length === 1 ? r[0] : e.reduce((s, o, i) => s + ((n) => {
|
|
46
28
|
if (n._$cssResult$ === !0) return n.cssText;
|
|
47
29
|
if (typeof n == "number") return n;
|
|
48
30
|
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.");
|
|
49
|
-
})(o) +
|
|
50
|
-
return new
|
|
51
|
-
},
|
|
52
|
-
if (
|
|
31
|
+
})(o) + r[i + 1], r[0]);
|
|
32
|
+
return new ae(t, r, V);
|
|
33
|
+
}, $e = (r, e) => {
|
|
34
|
+
if (G) r.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
|
|
53
35
|
else for (const t of e) {
|
|
54
|
-
const
|
|
55
|
-
o !== void 0 &&
|
|
36
|
+
const s = document.createElement("style"), o = q.litNonce;
|
|
37
|
+
o !== void 0 && s.setAttribute("nonce", o), s.textContent = t.cssText, r.appendChild(s);
|
|
56
38
|
}
|
|
57
|
-
},
|
|
39
|
+
}, Y = G ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((e) => {
|
|
58
40
|
let t = "";
|
|
59
|
-
for (const
|
|
60
|
-
return
|
|
61
|
-
})(
|
|
41
|
+
for (const s of e.cssRules) t += s.cssText;
|
|
42
|
+
return ge(t);
|
|
43
|
+
})(r) : r;
|
|
62
44
|
/**
|
|
63
45
|
* @license
|
|
64
46
|
* Copyright 2017 Google LLC
|
|
65
47
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
66
48
|
*/
|
|
67
|
-
const { is:
|
|
49
|
+
const { is: ye, defineProperty: be, getOwnPropertyDescriptor: _e, getOwnPropertyNames: we, getOwnPropertySymbols: ve, getPrototypeOf: Ae } = Object, $ = globalThis, Z = $.trustedTypes, Ee = Z ? Z.emptyScript : "", I = $.reactiveElementPolyfillSupport, U = (r, e) => r, W = { toAttribute(r, e) {
|
|
68
50
|
switch (e) {
|
|
69
51
|
case Boolean:
|
|
70
|
-
|
|
52
|
+
r = r ? Ee : null;
|
|
71
53
|
break;
|
|
72
54
|
case Object:
|
|
73
55
|
case Array:
|
|
74
|
-
|
|
56
|
+
r = r == null ? r : JSON.stringify(r);
|
|
75
57
|
}
|
|
76
|
-
return
|
|
77
|
-
}, fromAttribute(
|
|
78
|
-
let t =
|
|
58
|
+
return r;
|
|
59
|
+
}, fromAttribute(r, e) {
|
|
60
|
+
let t = r;
|
|
79
61
|
switch (e) {
|
|
80
62
|
case Boolean:
|
|
81
|
-
t =
|
|
63
|
+
t = r !== null;
|
|
82
64
|
break;
|
|
83
65
|
case Number:
|
|
84
|
-
t =
|
|
66
|
+
t = r === null ? null : Number(r);
|
|
85
67
|
break;
|
|
86
68
|
case Object:
|
|
87
69
|
case Array:
|
|
88
70
|
try {
|
|
89
|
-
t = JSON.parse(
|
|
71
|
+
t = JSON.parse(r);
|
|
90
72
|
} catch {
|
|
91
73
|
t = null;
|
|
92
74
|
}
|
|
93
75
|
}
|
|
94
76
|
return t;
|
|
95
|
-
} },
|
|
77
|
+
} }, le = (r, e) => !ye(r, e), X = { attribute: !0, type: String, converter: W, reflect: !1, hasChanged: le };
|
|
96
78
|
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $.litPropertyMetadata ?? ($.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
97
|
-
class
|
|
79
|
+
class S extends HTMLElement {
|
|
98
80
|
static addInitializer(e) {
|
|
99
81
|
this._$Ei(), (this.l ?? (this.l = [])).push(e);
|
|
100
82
|
}
|
|
101
83
|
static get observedAttributes() {
|
|
102
84
|
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
103
85
|
}
|
|
104
|
-
static createProperty(e, t =
|
|
86
|
+
static createProperty(e, t = X) {
|
|
105
87
|
if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
|
|
106
|
-
const
|
|
107
|
-
o !== void 0 &&
|
|
88
|
+
const s = Symbol(), o = this.getPropertyDescriptor(e, s, t);
|
|
89
|
+
o !== void 0 && be(this.prototype, e, o);
|
|
108
90
|
}
|
|
109
91
|
}
|
|
110
|
-
static getPropertyDescriptor(e, t,
|
|
111
|
-
const { get: o, set: i } =
|
|
92
|
+
static getPropertyDescriptor(e, t, s) {
|
|
93
|
+
const { get: o, set: i } = _e(this.prototype, e) ?? { get() {
|
|
112
94
|
return this[t];
|
|
113
95
|
}, set(n) {
|
|
114
96
|
this[t] = n;
|
|
@@ -117,31 +99,31 @@ class P extends HTMLElement {
|
|
|
117
99
|
return o == null ? void 0 : o.call(this);
|
|
118
100
|
}, set(n) {
|
|
119
101
|
const l = o == null ? void 0 : o.call(this);
|
|
120
|
-
i.call(this, n), this.requestUpdate(e, l,
|
|
102
|
+
i.call(this, n), this.requestUpdate(e, l, s);
|
|
121
103
|
}, configurable: !0, enumerable: !0 };
|
|
122
104
|
}
|
|
123
105
|
static getPropertyOptions(e) {
|
|
124
|
-
return this.elementProperties.get(e) ??
|
|
106
|
+
return this.elementProperties.get(e) ?? X;
|
|
125
107
|
}
|
|
126
108
|
static _$Ei() {
|
|
127
109
|
if (this.hasOwnProperty(U("elementProperties"))) return;
|
|
128
|
-
const e =
|
|
110
|
+
const e = Ae(this);
|
|
129
111
|
e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
|
|
130
112
|
}
|
|
131
113
|
static finalize() {
|
|
132
114
|
if (this.hasOwnProperty(U("finalized"))) return;
|
|
133
115
|
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(U("properties"))) {
|
|
134
|
-
const t = this.properties,
|
|
135
|
-
for (const o of
|
|
116
|
+
const t = this.properties, s = [...we(t), ...ve(t)];
|
|
117
|
+
for (const o of s) this.createProperty(o, t[o]);
|
|
136
118
|
}
|
|
137
119
|
const e = this[Symbol.metadata];
|
|
138
120
|
if (e !== null) {
|
|
139
121
|
const t = litPropertyMetadata.get(e);
|
|
140
|
-
if (t !== void 0) for (const [
|
|
122
|
+
if (t !== void 0) for (const [s, o] of t) this.elementProperties.set(s, o);
|
|
141
123
|
}
|
|
142
124
|
this._$Eh = /* @__PURE__ */ new Map();
|
|
143
|
-
for (const [t,
|
|
144
|
-
const o = this._$Eu(t,
|
|
125
|
+
for (const [t, s] of this.elementProperties) {
|
|
126
|
+
const o = this._$Eu(t, s);
|
|
145
127
|
o !== void 0 && this._$Eh.set(o, t);
|
|
146
128
|
}
|
|
147
129
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
@@ -149,14 +131,14 @@ class P extends HTMLElement {
|
|
|
149
131
|
static finalizeStyles(e) {
|
|
150
132
|
const t = [];
|
|
151
133
|
if (Array.isArray(e)) {
|
|
152
|
-
const
|
|
153
|
-
for (const o of
|
|
154
|
-
} else e !== void 0 && t.push(
|
|
134
|
+
const s = new Set(e.flat(1 / 0).reverse());
|
|
135
|
+
for (const o of s) t.unshift(Y(o));
|
|
136
|
+
} else e !== void 0 && t.push(Y(e));
|
|
155
137
|
return t;
|
|
156
138
|
}
|
|
157
139
|
static _$Eu(e, t) {
|
|
158
|
-
const
|
|
159
|
-
return
|
|
140
|
+
const s = t.attribute;
|
|
141
|
+
return s === !1 ? void 0 : typeof s == "string" ? s : typeof e == "string" ? e.toLowerCase() : void 0;
|
|
160
142
|
}
|
|
161
143
|
constructor() {
|
|
162
144
|
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
@@ -175,18 +157,18 @@ class P extends HTMLElement {
|
|
|
175
157
|
}
|
|
176
158
|
_$E_() {
|
|
177
159
|
const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
|
|
178
|
-
for (const
|
|
160
|
+
for (const s of t.keys()) this.hasOwnProperty(s) && (e.set(s, this[s]), delete this[s]);
|
|
179
161
|
e.size > 0 && (this._$Ep = e);
|
|
180
162
|
}
|
|
181
163
|
createRenderRoot() {
|
|
182
164
|
const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
183
|
-
return
|
|
165
|
+
return $e(e, this.constructor.elementStyles), e;
|
|
184
166
|
}
|
|
185
167
|
connectedCallback() {
|
|
186
168
|
var e;
|
|
187
169
|
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => {
|
|
188
|
-
var
|
|
189
|
-
return (
|
|
170
|
+
var s;
|
|
171
|
+
return (s = t.hostConnected) == null ? void 0 : s.call(t);
|
|
190
172
|
});
|
|
191
173
|
}
|
|
192
174
|
enableUpdating(e) {
|
|
@@ -194,38 +176,38 @@ class P extends HTMLElement {
|
|
|
194
176
|
disconnectedCallback() {
|
|
195
177
|
var e;
|
|
196
178
|
(e = this._$EO) == null || e.forEach((t) => {
|
|
197
|
-
var
|
|
198
|
-
return (
|
|
179
|
+
var s;
|
|
180
|
+
return (s = t.hostDisconnected) == null ? void 0 : s.call(t);
|
|
199
181
|
});
|
|
200
182
|
}
|
|
201
|
-
attributeChangedCallback(e, t,
|
|
202
|
-
this._$AK(e,
|
|
183
|
+
attributeChangedCallback(e, t, s) {
|
|
184
|
+
this._$AK(e, s);
|
|
203
185
|
}
|
|
204
186
|
_$EC(e, t) {
|
|
205
187
|
var i;
|
|
206
|
-
const
|
|
207
|
-
if (o !== void 0 &&
|
|
208
|
-
const n = (((i =
|
|
188
|
+
const s = this.constructor.elementProperties.get(e), o = this.constructor._$Eu(e, s);
|
|
189
|
+
if (o !== void 0 && s.reflect === !0) {
|
|
190
|
+
const n = (((i = s.converter) == null ? void 0 : i.toAttribute) !== void 0 ? s.converter : W).toAttribute(t, s.type);
|
|
209
191
|
this._$Em = e, n == null ? this.removeAttribute(o) : this.setAttribute(o, n), this._$Em = null;
|
|
210
192
|
}
|
|
211
193
|
}
|
|
212
194
|
_$AK(e, t) {
|
|
213
195
|
var i;
|
|
214
|
-
const
|
|
196
|
+
const s = this.constructor, o = s._$Eh.get(e);
|
|
215
197
|
if (o !== void 0 && this._$Em !== o) {
|
|
216
|
-
const n =
|
|
198
|
+
const n = s.getPropertyOptions(o), l = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((i = n.converter) == null ? void 0 : i.fromAttribute) !== void 0 ? n.converter : W;
|
|
217
199
|
this._$Em = o, this[o] = l.fromAttribute(t, n.type), this._$Em = null;
|
|
218
200
|
}
|
|
219
201
|
}
|
|
220
|
-
requestUpdate(e, t,
|
|
202
|
+
requestUpdate(e, t, s) {
|
|
221
203
|
if (e !== void 0) {
|
|
222
|
-
if (
|
|
223
|
-
this.P(e, t,
|
|
204
|
+
if (s ?? (s = this.constructor.getPropertyOptions(e)), !(s.hasChanged ?? le)(this[e], t)) return;
|
|
205
|
+
this.P(e, t, s);
|
|
224
206
|
}
|
|
225
207
|
this.isUpdatePending === !1 && (this._$ES = this._$ET());
|
|
226
208
|
}
|
|
227
|
-
P(e, t,
|
|
228
|
-
this._$AL.has(e) || this._$AL.set(e, t),
|
|
209
|
+
P(e, t, s) {
|
|
210
|
+
this._$AL.has(e) || this._$AL.set(e, t), s.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e);
|
|
229
211
|
}
|
|
230
212
|
async _$ET() {
|
|
231
213
|
this.isUpdatePending = !0;
|
|
@@ -241,7 +223,7 @@ class P extends HTMLElement {
|
|
|
241
223
|
return this.performUpdate();
|
|
242
224
|
}
|
|
243
225
|
performUpdate() {
|
|
244
|
-
var
|
|
226
|
+
var s;
|
|
245
227
|
if (!this.isUpdatePending) return;
|
|
246
228
|
if (!this.hasUpdated) {
|
|
247
229
|
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
@@ -254,7 +236,7 @@ class P extends HTMLElement {
|
|
|
254
236
|
let e = !1;
|
|
255
237
|
const t = this._$AL;
|
|
256
238
|
try {
|
|
257
|
-
e = this.shouldUpdate(t), e ? (this.willUpdate(t), (
|
|
239
|
+
e = this.shouldUpdate(t), e ? (this.willUpdate(t), (s = this._$EO) == null || s.forEach((o) => {
|
|
258
240
|
var i;
|
|
259
241
|
return (i = o.hostUpdate) == null ? void 0 : i.call(o);
|
|
260
242
|
}), this.update(t)) : this._$EU();
|
|
@@ -267,9 +249,9 @@ class P extends HTMLElement {
|
|
|
267
249
|
}
|
|
268
250
|
_$AE(e) {
|
|
269
251
|
var t;
|
|
270
|
-
(t = this._$EO) == null || t.forEach((
|
|
252
|
+
(t = this._$EO) == null || t.forEach((s) => {
|
|
271
253
|
var o;
|
|
272
|
-
return (o =
|
|
254
|
+
return (o = s.hostUpdated) == null ? void 0 : o.call(s);
|
|
273
255
|
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
|
|
274
256
|
}
|
|
275
257
|
_$EU() {
|
|
@@ -292,76 +274,76 @@ class P extends HTMLElement {
|
|
|
292
274
|
firstUpdated(e) {
|
|
293
275
|
}
|
|
294
276
|
}
|
|
295
|
-
|
|
277
|
+
S.elementStyles = [], S.shadowRootOptions = { mode: "open" }, S[U("elementProperties")] = /* @__PURE__ */ new Map(), S[U("finalized")] = /* @__PURE__ */ new Map(), I == null || I({ ReactiveElement: S }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4");
|
|
296
278
|
/**
|
|
297
279
|
* @license
|
|
298
280
|
* Copyright 2017 Google LLC
|
|
299
281
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
300
282
|
*/
|
|
301
|
-
const
|
|
302
|
-
\f\r]`,
|
|
303
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"),
|
|
304
|
-
function
|
|
305
|
-
if (!
|
|
306
|
-
return
|
|
283
|
+
const T = globalThis, M = T.trustedTypes, ee = M ? M.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, he = "$lit$", g = `lit$${Math.random().toFixed(9).slice(2)}$`, ce = "?" + g, Se = `<${ce}>`, A = document, k = () => A.createComment(""), R = (r) => r === null || typeof r != "object" && typeof r != "function", Q = Array.isArray, Ce = (r) => Q(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", z = `[
|
|
284
|
+
\f\r]`, x = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, te = /-->/g, se = />/g, b = RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^
|
|
285
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), re = /'/g, oe = /"/g, de = /^(?:script|style|textarea|title)$/i, Pe = (r) => (e, ...t) => ({ _$litType$: r, strings: e, values: t }), p = Pe(1), C = Symbol.for("lit-noChange"), u = Symbol.for("lit-nothing"), ie = /* @__PURE__ */ new WeakMap(), w = A.createTreeWalker(A, 129);
|
|
286
|
+
function ue(r, e) {
|
|
287
|
+
if (!Q(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
288
|
+
return ee !== void 0 ? ee.createHTML(e) : e;
|
|
307
289
|
}
|
|
308
|
-
const
|
|
309
|
-
const t =
|
|
310
|
-
let o, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n =
|
|
290
|
+
const xe = (r, e) => {
|
|
291
|
+
const t = r.length - 1, s = [];
|
|
292
|
+
let o, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = x;
|
|
311
293
|
for (let l = 0; l < t; l++) {
|
|
312
|
-
const a =
|
|
313
|
-
let
|
|
314
|
-
for (; m < a.length && (n.lastIndex = m,
|
|
315
|
-
const f = n ===
|
|
316
|
-
i += n ===
|
|
294
|
+
const a = r[l];
|
|
295
|
+
let d, h, c = -1, m = 0;
|
|
296
|
+
for (; m < a.length && (n.lastIndex = m, h = n.exec(a), h !== null); ) m = n.lastIndex, n === x ? h[1] === "!--" ? n = te : h[1] !== void 0 ? n = se : h[2] !== void 0 ? (de.test(h[2]) && (o = RegExp("</" + h[2], "g")), n = b) : h[3] !== void 0 && (n = b) : n === b ? h[0] === ">" ? (n = o ?? x, c = -1) : h[1] === void 0 ? c = -2 : (c = n.lastIndex - h[2].length, d = h[1], n = h[3] === void 0 ? b : h[3] === '"' ? oe : re) : n === oe || n === re ? n = b : n === te || n === se ? n = x : (n = b, o = void 0);
|
|
297
|
+
const f = n === b && r[l + 1].startsWith("/>") ? " " : "";
|
|
298
|
+
i += n === x ? a + Se : c >= 0 ? (s.push(d), a.slice(0, c) + he + a.slice(c) + g + f) : a + g + (c === -2 ? l : f);
|
|
317
299
|
}
|
|
318
|
-
return [
|
|
300
|
+
return [ue(r, i + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
|
|
319
301
|
};
|
|
320
|
-
class
|
|
321
|
-
constructor({ strings: e, _$litType$: t },
|
|
302
|
+
class O {
|
|
303
|
+
constructor({ strings: e, _$litType$: t }, s) {
|
|
322
304
|
let o;
|
|
323
305
|
this.parts = [];
|
|
324
306
|
let i = 0, n = 0;
|
|
325
|
-
const l = e.length - 1, a = this.parts, [
|
|
326
|
-
if (this.el =
|
|
327
|
-
const
|
|
328
|
-
|
|
307
|
+
const l = e.length - 1, a = this.parts, [d, h] = xe(e, t);
|
|
308
|
+
if (this.el = O.createElement(d, s), w.currentNode = this.el.content, t === 2 || t === 3) {
|
|
309
|
+
const c = this.el.content.firstChild;
|
|
310
|
+
c.replaceWith(...c.childNodes);
|
|
329
311
|
}
|
|
330
|
-
for (; (o =
|
|
312
|
+
for (; (o = w.nextNode()) !== null && a.length < l; ) {
|
|
331
313
|
if (o.nodeType === 1) {
|
|
332
|
-
if (o.hasAttributes()) for (const
|
|
333
|
-
const m =
|
|
334
|
-
a.push({ type: 1, index: i, name:
|
|
335
|
-
} else
|
|
336
|
-
if (
|
|
337
|
-
const
|
|
314
|
+
if (o.hasAttributes()) for (const c of o.getAttributeNames()) if (c.endsWith(he)) {
|
|
315
|
+
const m = h[n++], f = o.getAttribute(c).split(g), y = /([.?@])?(.*)/.exec(m);
|
|
316
|
+
a.push({ type: 1, index: i, name: y[2], strings: f, ctor: y[1] === "." ? Te : y[1] === "?" ? ke : y[1] === "@" ? Re : D }), o.removeAttribute(c);
|
|
317
|
+
} else c.startsWith(g) && (a.push({ type: 6, index: i }), o.removeAttribute(c));
|
|
318
|
+
if (de.test(o.tagName)) {
|
|
319
|
+
const c = o.textContent.split(g), m = c.length - 1;
|
|
338
320
|
if (m > 0) {
|
|
339
321
|
o.textContent = M ? M.emptyScript : "";
|
|
340
|
-
for (let f = 0; f < m; f++) o.append(
|
|
341
|
-
o.append(
|
|
322
|
+
for (let f = 0; f < m; f++) o.append(c[f], k()), w.nextNode(), a.push({ type: 2, index: ++i });
|
|
323
|
+
o.append(c[m], k());
|
|
342
324
|
}
|
|
343
325
|
}
|
|
344
|
-
} else if (o.nodeType === 8) if (o.data ===
|
|
326
|
+
} else if (o.nodeType === 8) if (o.data === ce) a.push({ type: 2, index: i });
|
|
345
327
|
else {
|
|
346
|
-
let
|
|
347
|
-
for (; (
|
|
328
|
+
let c = -1;
|
|
329
|
+
for (; (c = o.data.indexOf(g, c + 1)) !== -1; ) a.push({ type: 7, index: i }), c += g.length - 1;
|
|
348
330
|
}
|
|
349
331
|
i++;
|
|
350
332
|
}
|
|
351
333
|
}
|
|
352
334
|
static createElement(e, t) {
|
|
353
|
-
const
|
|
354
|
-
return
|
|
335
|
+
const s = A.createElement("template");
|
|
336
|
+
return s.innerHTML = e, s;
|
|
355
337
|
}
|
|
356
338
|
}
|
|
357
|
-
function
|
|
339
|
+
function P(r, e, t = r, s) {
|
|
358
340
|
var n, l;
|
|
359
|
-
if (e ===
|
|
360
|
-
let o =
|
|
361
|
-
const 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(
|
|
341
|
+
if (e === C) return e;
|
|
342
|
+
let o = s !== void 0 ? (n = t._$Co) == null ? void 0 : n[s] : t._$Cl;
|
|
343
|
+
const i = R(e) ? void 0 : e._$litDirective$;
|
|
344
|
+
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(r), o._$AT(r, t, s)), s !== void 0 ? (t._$Co ?? (t._$Co = []))[s] = o : t._$Cl = o), o !== void 0 && (e = P(r, o._$AS(r, e.values), o, s)), e;
|
|
363
345
|
}
|
|
364
|
-
class
|
|
346
|
+
class Ue {
|
|
365
347
|
constructor(e, t) {
|
|
366
348
|
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
|
|
367
349
|
}
|
|
@@ -372,30 +354,30 @@ class He {
|
|
|
372
354
|
return this._$AM._$AU;
|
|
373
355
|
}
|
|
374
356
|
u(e) {
|
|
375
|
-
const { el: { content: t }, parts:
|
|
376
|
-
|
|
377
|
-
let i =
|
|
357
|
+
const { el: { content: t }, parts: s } = this._$AD, o = ((e == null ? void 0 : e.creationScope) ?? A).importNode(t, !0);
|
|
358
|
+
w.currentNode = o;
|
|
359
|
+
let i = w.nextNode(), n = 0, l = 0, a = s[0];
|
|
378
360
|
for (; a !== void 0; ) {
|
|
379
361
|
if (n === a.index) {
|
|
380
|
-
let
|
|
381
|
-
a.type === 2 ?
|
|
362
|
+
let d;
|
|
363
|
+
a.type === 2 ? d = new H(i, i.nextSibling, this, e) : a.type === 1 ? d = new a.ctor(i, a.name, a.strings, this, e) : a.type === 6 && (d = new Oe(i, this, e)), this._$AV.push(d), a = s[++l];
|
|
382
364
|
}
|
|
383
|
-
n !== (a == null ? void 0 : a.index) && (i =
|
|
365
|
+
n !== (a == null ? void 0 : a.index) && (i = w.nextNode(), n++);
|
|
384
366
|
}
|
|
385
|
-
return
|
|
367
|
+
return w.currentNode = A, o;
|
|
386
368
|
}
|
|
387
369
|
p(e) {
|
|
388
370
|
let t = 0;
|
|
389
|
-
for (const
|
|
371
|
+
for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
|
|
390
372
|
}
|
|
391
373
|
}
|
|
392
|
-
class
|
|
374
|
+
class H {
|
|
393
375
|
get _$AU() {
|
|
394
376
|
var e;
|
|
395
377
|
return ((e = this._$AM) == null ? void 0 : e._$AU) ?? this._$Cv;
|
|
396
378
|
}
|
|
397
|
-
constructor(e, t,
|
|
398
|
-
this.type = 2, this._$AH =
|
|
379
|
+
constructor(e, t, s, o) {
|
|
380
|
+
this.type = 2, this._$AH = u, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = o, this._$Cv = (o == null ? void 0 : o.isConnected) ?? !0;
|
|
399
381
|
}
|
|
400
382
|
get parentNode() {
|
|
401
383
|
let e = this._$AA.parentNode;
|
|
@@ -409,7 +391,7 @@ class D {
|
|
|
409
391
|
return this._$AB;
|
|
410
392
|
}
|
|
411
393
|
_$AI(e, t = this) {
|
|
412
|
-
e =
|
|
394
|
+
e = P(this, e, t), R(e) ? e === u || e == null || e === "" ? (this._$AH !== u && this._$AR(), this._$AH = u) : e !== this._$AH && e !== C && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Ce(e) ? this.k(e) : this._(e);
|
|
413
395
|
}
|
|
414
396
|
O(e) {
|
|
415
397
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -418,31 +400,31 @@ class D {
|
|
|
418
400
|
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
419
401
|
}
|
|
420
402
|
_(e) {
|
|
421
|
-
this._$AH !==
|
|
403
|
+
this._$AH !== u && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(A.createTextNode(e)), this._$AH = e;
|
|
422
404
|
}
|
|
423
405
|
$(e) {
|
|
424
406
|
var i;
|
|
425
|
-
const { values: t, _$litType$:
|
|
407
|
+
const { values: t, _$litType$: s } = e, o = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = O.createElement(ue(s.h, s.h[0]), this.options)), s);
|
|
426
408
|
if (((i = this._$AH) == null ? void 0 : i._$AD) === o) this._$AH.p(t);
|
|
427
409
|
else {
|
|
428
|
-
const n = new
|
|
410
|
+
const n = new Ue(o, this), l = n.u(this.options);
|
|
429
411
|
n.p(t), this.T(l), this._$AH = n;
|
|
430
412
|
}
|
|
431
413
|
}
|
|
432
414
|
_$AC(e) {
|
|
433
|
-
let t =
|
|
434
|
-
return t === void 0 &&
|
|
415
|
+
let t = ie.get(e.strings);
|
|
416
|
+
return t === void 0 && ie.set(e.strings, t = new O(e)), t;
|
|
435
417
|
}
|
|
436
418
|
k(e) {
|
|
437
|
-
|
|
419
|
+
Q(this._$AH) || (this._$AH = [], this._$AR());
|
|
438
420
|
const t = this._$AH;
|
|
439
|
-
let
|
|
440
|
-
for (const i of e) o === t.length ? t.push(
|
|
441
|
-
o < t.length && (this._$AR(
|
|
421
|
+
let s, o = 0;
|
|
422
|
+
for (const i of e) o === t.length ? t.push(s = new H(this.O(k()), this.O(k()), this, this.options)) : s = t[o], s._$AI(i), o++;
|
|
423
|
+
o < t.length && (this._$AR(s && s._$AB.nextSibling, o), t.length = o);
|
|
442
424
|
}
|
|
443
425
|
_$AR(e = this._$AA.nextSibling, t) {
|
|
444
|
-
var
|
|
445
|
-
for ((
|
|
426
|
+
var s;
|
|
427
|
+
for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, t); e && e !== this._$AB; ) {
|
|
446
428
|
const o = e.nextSibling;
|
|
447
429
|
e.remove(), e = o;
|
|
448
430
|
}
|
|
@@ -452,89 +434,89 @@ class D {
|
|
|
452
434
|
this._$AM === void 0 && (this._$Cv = e, (t = this._$AP) == null || t.call(this, e));
|
|
453
435
|
}
|
|
454
436
|
}
|
|
455
|
-
class
|
|
437
|
+
class D {
|
|
456
438
|
get tagName() {
|
|
457
439
|
return this.element.tagName;
|
|
458
440
|
}
|
|
459
441
|
get _$AU() {
|
|
460
442
|
return this._$AM._$AU;
|
|
461
443
|
}
|
|
462
|
-
constructor(e, t,
|
|
463
|
-
this.type = 1, this._$AH =
|
|
444
|
+
constructor(e, t, s, o, i) {
|
|
445
|
+
this.type = 1, this._$AH = u, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = i, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = u;
|
|
464
446
|
}
|
|
465
|
-
_$AI(e, t = this,
|
|
447
|
+
_$AI(e, t = this, s, o) {
|
|
466
448
|
const i = this.strings;
|
|
467
449
|
let n = !1;
|
|
468
|
-
if (i === void 0) e =
|
|
450
|
+
if (i === void 0) e = P(this, e, t, 0), n = !R(e) || e !== this._$AH && e !== C, n && (this._$AH = e);
|
|
469
451
|
else {
|
|
470
452
|
const l = e;
|
|
471
|
-
let a,
|
|
472
|
-
for (e = i[0], a = 0; a < i.length - 1; a++)
|
|
453
|
+
let a, d;
|
|
454
|
+
for (e = i[0], a = 0; a < i.length - 1; a++) d = P(this, l[s + a], t, a), d === C && (d = this._$AH[a]), n || (n = !R(d) || d !== this._$AH[a]), d === u ? e = u : e !== u && (e += (d ?? "") + i[a + 1]), this._$AH[a] = d;
|
|
473
455
|
}
|
|
474
456
|
n && !o && this.j(e);
|
|
475
457
|
}
|
|
476
458
|
j(e) {
|
|
477
|
-
e ===
|
|
459
|
+
e === u ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
478
460
|
}
|
|
479
461
|
}
|
|
480
|
-
class
|
|
462
|
+
class Te extends D {
|
|
481
463
|
constructor() {
|
|
482
464
|
super(...arguments), this.type = 3;
|
|
483
465
|
}
|
|
484
466
|
j(e) {
|
|
485
|
-
this.element[this.name] = e ===
|
|
467
|
+
this.element[this.name] = e === u ? void 0 : e;
|
|
486
468
|
}
|
|
487
469
|
}
|
|
488
|
-
class
|
|
470
|
+
class ke extends D {
|
|
489
471
|
constructor() {
|
|
490
472
|
super(...arguments), this.type = 4;
|
|
491
473
|
}
|
|
492
474
|
j(e) {
|
|
493
|
-
this.element.toggleAttribute(this.name, !!e && e !==
|
|
475
|
+
this.element.toggleAttribute(this.name, !!e && e !== u);
|
|
494
476
|
}
|
|
495
477
|
}
|
|
496
|
-
class
|
|
497
|
-
constructor(e, t,
|
|
498
|
-
super(e, t,
|
|
478
|
+
class Re extends D {
|
|
479
|
+
constructor(e, t, s, o, i) {
|
|
480
|
+
super(e, t, s, o, i), this.type = 5;
|
|
499
481
|
}
|
|
500
482
|
_$AI(e, t = this) {
|
|
501
|
-
if ((e =
|
|
502
|
-
const
|
|
503
|
-
o && this.element.removeEventListener(this.name, this,
|
|
483
|
+
if ((e = P(this, e, t, 0) ?? u) === C) return;
|
|
484
|
+
const s = this._$AH, o = e === u && s !== u || e.capture !== s.capture || e.once !== s.once || e.passive !== s.passive, i = e !== u && (s === u || o);
|
|
485
|
+
o && this.element.removeEventListener(this.name, this, s), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
504
486
|
}
|
|
505
487
|
handleEvent(e) {
|
|
506
488
|
var t;
|
|
507
489
|
typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e);
|
|
508
490
|
}
|
|
509
491
|
}
|
|
510
|
-
class
|
|
511
|
-
constructor(e, t,
|
|
512
|
-
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options =
|
|
492
|
+
class Oe {
|
|
493
|
+
constructor(e, t, s) {
|
|
494
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
|
|
513
495
|
}
|
|
514
496
|
get _$AU() {
|
|
515
497
|
return this._$AM._$AU;
|
|
516
498
|
}
|
|
517
499
|
_$AI(e) {
|
|
518
|
-
|
|
500
|
+
P(this, e);
|
|
519
501
|
}
|
|
520
502
|
}
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
let o =
|
|
503
|
+
const j = T.litHtmlPolyfillSupport;
|
|
504
|
+
j == null || j(O, H), (T.litHtmlVersions ?? (T.litHtmlVersions = [])).push("3.2.1");
|
|
505
|
+
const Ne = (r, e, t) => {
|
|
506
|
+
const s = (t == null ? void 0 : t.renderBefore) ?? e;
|
|
507
|
+
let o = s._$litPart$;
|
|
526
508
|
if (o === void 0) {
|
|
527
509
|
const i = (t == null ? void 0 : t.renderBefore) ?? null;
|
|
528
|
-
|
|
510
|
+
s._$litPart$ = o = new H(e.insertBefore(k(), i), i, void 0, t ?? {});
|
|
529
511
|
}
|
|
530
|
-
return o._$AI(
|
|
512
|
+
return o._$AI(r), o;
|
|
531
513
|
};
|
|
532
514
|
/**
|
|
533
515
|
* @license
|
|
534
516
|
* Copyright 2017 Google LLC
|
|
535
517
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
536
518
|
*/
|
|
537
|
-
class
|
|
519
|
+
class v extends S {
|
|
538
520
|
constructor() {
|
|
539
521
|
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
|
|
540
522
|
}
|
|
@@ -545,7 +527,7 @@ class b extends P {
|
|
|
545
527
|
}
|
|
546
528
|
update(e) {
|
|
547
529
|
const t = this.render();
|
|
548
|
-
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do =
|
|
530
|
+
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = Ne(t, this.renderRoot, this.renderOptions);
|
|
549
531
|
}
|
|
550
532
|
connectedCallback() {
|
|
551
533
|
var e;
|
|
@@ -556,28 +538,57 @@ class b extends P {
|
|
|
556
538
|
super.disconnectedCallback(), (e = this._$Do) == null || e.setConnected(!1);
|
|
557
539
|
}
|
|
558
540
|
render() {
|
|
559
|
-
return
|
|
541
|
+
return C;
|
|
560
542
|
}
|
|
561
543
|
}
|
|
562
|
-
var
|
|
563
|
-
|
|
544
|
+
var ne;
|
|
545
|
+
v._$litElement$ = !0, v.finalized = !0, (ne = globalThis.litElementHydrateSupport) == null || ne.call(globalThis, { LitElement: v });
|
|
564
546
|
const B = globalThis.litElementPolyfillSupport;
|
|
565
|
-
B == null || B({ LitElement:
|
|
547
|
+
B == null || B({ LitElement: v });
|
|
566
548
|
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
|
|
567
|
-
|
|
549
|
+
class He extends v {
|
|
550
|
+
static get styles() {
|
|
551
|
+
return J`
|
|
552
|
+
.login-layout {
|
|
553
|
+
display: flex;
|
|
554
|
+
flex-direction: column;
|
|
555
|
+
gap: 1rem;
|
|
556
|
+
justify-content: center;
|
|
557
|
+
align-items: center;
|
|
558
|
+
min-height: 100vh;
|
|
559
|
+
background-color: var(--color-gray-100);
|
|
560
|
+
}
|
|
561
|
+
.login-layout > * {
|
|
562
|
+
max-width: 400px;
|
|
563
|
+
}
|
|
564
|
+
`;
|
|
565
|
+
}
|
|
566
|
+
render() {
|
|
567
|
+
return p`
|
|
568
|
+
<div class="login-layout">
|
|
569
|
+
<slot name="main"></slot>
|
|
570
|
+
</div>
|
|
571
|
+
`;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
customElements.get("mod-auth-layout") === void 0 && customElements.define("mod-auth-layout", He);
|
|
575
|
+
function Le() {
|
|
576
|
+
return p`<mod-auth-layout></mod-auth-layout>`;
|
|
577
|
+
}
|
|
578
|
+
function N(r) {
|
|
568
579
|
return {
|
|
569
580
|
// Underlying mechanism to use the REST URLs directly.
|
|
570
|
-
api: (e, t) => E(
|
|
571
|
-
mintToken: ({ username: e, password: t }) =>
|
|
572
|
-
refreshToken: ({ token: e }) =>
|
|
573
|
-
pubkey: () =>
|
|
574
|
-
updatePassword: ({ token: e, currentPassword: t, newPassword:
|
|
575
|
-
triggerResetPassword: ({ username: e }) =>
|
|
576
|
-
confirmResetPassword: ({ username: e, newPassword: t, confirmationCode:
|
|
581
|
+
api: (e, t) => E(r, e, t),
|
|
582
|
+
mintToken: ({ username: e, password: t }) => Fe({ config: r, username: e, password: t }),
|
|
583
|
+
refreshToken: ({ token: e }) => qe({ config: r, token: e }),
|
|
584
|
+
pubkey: () => Me({ config: r }),
|
|
585
|
+
updatePassword: ({ token: e, currentPassword: t, newPassword: s }) => De({ config: r, token: e, currentPassword: t, newPassword: s }),
|
|
586
|
+
triggerResetPassword: ({ username: e }) => Ie({ config: r, username: e }),
|
|
587
|
+
confirmResetPassword: ({ username: e, newPassword: t, confirmationCode: s }) => ze({ config: r, username: e, newPassword: t, confirmationCode: s })
|
|
577
588
|
};
|
|
578
589
|
}
|
|
579
|
-
function
|
|
580
|
-
return E(
|
|
590
|
+
function Fe({ config: r, username: e, password: t }) {
|
|
591
|
+
return E(r, "/v1/user/login", {
|
|
581
592
|
method: "POST",
|
|
582
593
|
body: {
|
|
583
594
|
username: e,
|
|
@@ -585,93 +596,92 @@ function Ie({ config: s, username: e, password: t }) {
|
|
|
585
596
|
}
|
|
586
597
|
});
|
|
587
598
|
}
|
|
588
|
-
function
|
|
589
|
-
return E(
|
|
599
|
+
function qe({ config: r, token: e }) {
|
|
600
|
+
return E(r, "/v1/refresh", {
|
|
590
601
|
method: "POST",
|
|
591
602
|
body: {
|
|
592
603
|
token: e
|
|
593
604
|
}
|
|
594
605
|
});
|
|
595
606
|
}
|
|
596
|
-
function
|
|
597
|
-
return E(
|
|
607
|
+
function Me({ config: r }) {
|
|
608
|
+
return E(r, "/v1/pubkey", {
|
|
598
609
|
method: "GET"
|
|
599
610
|
});
|
|
600
611
|
}
|
|
601
|
-
function
|
|
602
|
-
return E(
|
|
612
|
+
function De({ config: r, token: e, currentPassword: t, newPassword: s }) {
|
|
613
|
+
return E(r, "/v1/user/password", {
|
|
603
614
|
method: "PUT",
|
|
604
615
|
body: {
|
|
605
616
|
currentPassword: t,
|
|
606
|
-
newPassword:
|
|
617
|
+
newPassword: s
|
|
607
618
|
},
|
|
608
619
|
headers: {
|
|
609
620
|
Authorization: `Bearer ${e}`
|
|
610
621
|
}
|
|
611
622
|
});
|
|
612
623
|
}
|
|
613
|
-
function
|
|
614
|
-
return E(
|
|
624
|
+
function Ie({ config: r, username: e }) {
|
|
625
|
+
return E(r, "/v1/user/password/reset", {
|
|
615
626
|
method: "POST",
|
|
616
627
|
body: {
|
|
617
628
|
username: e
|
|
618
629
|
}
|
|
619
630
|
});
|
|
620
631
|
}
|
|
621
|
-
function
|
|
622
|
-
return E(
|
|
632
|
+
function ze({ config: r, username: e, newPassword: t, confirmationCode: s }) {
|
|
633
|
+
return E(r, "/v1/user/password/reset/confirm", {
|
|
623
634
|
method: "POST",
|
|
624
635
|
body: {
|
|
625
636
|
username: e,
|
|
626
637
|
newPassword: t,
|
|
627
|
-
confirmationCode:
|
|
638
|
+
confirmationCode: s
|
|
628
639
|
}
|
|
629
640
|
});
|
|
630
641
|
}
|
|
631
|
-
async function E(
|
|
632
|
-
var
|
|
633
|
-
const
|
|
642
|
+
async function E(r, e, t) {
|
|
643
|
+
var d;
|
|
644
|
+
const s = r.baseUrl.endsWith("/") ? r.baseUrl : `${r.baseUrl}/`, o = e.startsWith("/") ? e.substring(1) : e, i = new URL(o, s), l = Object.assign({}, t, {
|
|
634
645
|
headers: Object.assign({}, {
|
|
635
646
|
"Content-Type": "application/json"
|
|
636
647
|
}, t == null ? void 0 : t.headers),
|
|
637
648
|
body: t != null && t.body ? JSON.stringify(t.body) : void 0
|
|
638
649
|
}), a = await fetch(i.toString(), l);
|
|
639
650
|
if (!a.ok) {
|
|
640
|
-
const
|
|
641
|
-
if (
|
|
651
|
+
const h = new Error("API request failed.");
|
|
652
|
+
if (h.status = a.status, h.statusText = a.statusText, h.url = i.toString(), h.headers = a.headers, h.bodyUsed = a.bodyUsed, (d = a.headers.get("Content-Type")) != null && d.includes("application/json"))
|
|
642
653
|
try {
|
|
643
|
-
|
|
654
|
+
h.body = await a.json();
|
|
644
655
|
} catch {
|
|
645
|
-
|
|
656
|
+
h.body = "Failed to parse response body.";
|
|
646
657
|
}
|
|
647
|
-
throw
|
|
658
|
+
throw h;
|
|
648
659
|
}
|
|
649
660
|
if (a.status !== 204)
|
|
650
661
|
return await a.json();
|
|
651
662
|
}
|
|
652
|
-
|
|
653
|
-
const t = x({
|
|
654
|
-
baseUrl: s
|
|
655
|
-
});
|
|
656
|
-
return console.log("sending credentials to API", s), t.mintToken(e);
|
|
657
|
-
}
|
|
658
|
-
const g = Object.freeze({
|
|
663
|
+
const _ = Object.freeze({
|
|
659
664
|
REQUEST: "request",
|
|
660
665
|
CONFIRM: "confirm",
|
|
661
666
|
FINISHED: "finished"
|
|
662
667
|
});
|
|
663
|
-
class
|
|
668
|
+
class je extends v {
|
|
664
669
|
static get properties() {
|
|
665
670
|
return {
|
|
666
|
-
api: { type: String
|
|
667
|
-
confirmation: { type: "String", attribute: "confirmation" }
|
|
671
|
+
api: { type: String }
|
|
668
672
|
};
|
|
669
673
|
}
|
|
670
674
|
static get styles() {
|
|
671
|
-
return
|
|
675
|
+
return J`
|
|
672
676
|
:host {
|
|
673
|
-
display:
|
|
674
|
-
|
|
677
|
+
display: flex;
|
|
678
|
+
flex-direction: column;
|
|
679
|
+
justify-content: center;
|
|
680
|
+
align-items: center;
|
|
681
|
+
}
|
|
682
|
+
form {
|
|
683
|
+
display: flex;
|
|
684
|
+
flex-direction: column;
|
|
675
685
|
}
|
|
676
686
|
form input[type="text"],
|
|
677
687
|
form input[type="password"] {
|
|
@@ -679,14 +689,14 @@ class Ve extends b {
|
|
|
679
689
|
margin: 5px 0 15px 0;
|
|
680
690
|
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
681
691
|
box-sizing: border-box;
|
|
682
|
-
border: 1px solid var(--color-gray-300, #
|
|
683
|
-
border-radius: var(--radius-sm,
|
|
684
|
-
color: var(--color-gray-
|
|
685
|
-
background-color: var(--color-gray-
|
|
692
|
+
border: 1px solid var(--color-gray-300, #CCC);
|
|
693
|
+
border-radius: var(--radius-sm, 3px);
|
|
694
|
+
color: var(--color-gray-700, #333);
|
|
695
|
+
background-color: var(--color-gray-50, #FFF);
|
|
686
696
|
}
|
|
687
697
|
form input[type="submit"] {
|
|
688
|
-
background-color:var(--color-primary, inherit);
|
|
689
|
-
color: var(--color-gray-
|
|
698
|
+
background-color: var(--color-primary, inherit);
|
|
699
|
+
color: var(--color-gray-50, #fff);
|
|
690
700
|
border: none;
|
|
691
701
|
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
692
702
|
border-radius: var(--radius-dynamic, 5px);
|
|
@@ -697,81 +707,84 @@ class Ve extends b {
|
|
|
697
707
|
}
|
|
698
708
|
form label {
|
|
699
709
|
font-size: 14px;
|
|
700
|
-
color: var(--color-gray-
|
|
710
|
+
color: var(--color-gray-700, #333);
|
|
701
711
|
font-weight: bold;
|
|
702
712
|
margin-bottom: var(--spacing-sm, 0.5rem);
|
|
703
713
|
}
|
|
704
714
|
.error {
|
|
705
715
|
color: var(--color-danger, red);
|
|
706
|
-
font-size:
|
|
716
|
+
font-size: 14px;
|
|
707
717
|
}
|
|
708
718
|
`;
|
|
709
719
|
}
|
|
710
720
|
constructor() {
|
|
711
|
-
super(), this.errors = {}, this.stage =
|
|
721
|
+
super(), this.errors = {}, this.stage = _.REQUEST;
|
|
712
722
|
}
|
|
713
723
|
connectedCallback() {
|
|
714
|
-
|
|
724
|
+
super.connectedCallback(), this.confirmToken && this.stage !== _.FINISHED && this.setStage(_.CONFIRM);
|
|
725
|
+
}
|
|
726
|
+
setStage(e) {
|
|
727
|
+
this.stage !== e && (this.stage = e, this.requestUpdate());
|
|
715
728
|
}
|
|
716
729
|
handleSubmitRequest(e) {
|
|
717
730
|
e.preventDefault();
|
|
718
731
|
const t = e.target.username.value;
|
|
719
|
-
this.username = t,
|
|
720
|
-
|
|
721
|
-
}).triggerResetPassword({ username: t }).then(() => {
|
|
722
|
-
console.log("[auth]", "triggered reset password for ", t), this.stage = g.CONFIRM;
|
|
732
|
+
this.username = t, N({ baseUrl: this.api }).triggerResetPassword({ username: t }).then(() => {
|
|
733
|
+
this.setStage(_.CONFIRM);
|
|
723
734
|
}).catch((o) => {
|
|
724
|
-
|
|
735
|
+
this.errors.general = o.message || "Unable to send password reset request. Please try again later.";
|
|
725
736
|
}).finally(() => {
|
|
726
737
|
this.requestUpdate();
|
|
727
738
|
});
|
|
728
739
|
}
|
|
729
740
|
handleSubmitConfirm(e) {
|
|
730
741
|
e.preventDefault();
|
|
731
|
-
const t = e.target.password.value,
|
|
732
|
-
if (t !==
|
|
733
|
-
this.errors["confirm-password"] = "Passwords do not match
|
|
742
|
+
const t = e.target.password.value, s = e.target["confirm-password"].value;
|
|
743
|
+
if (t !== s) {
|
|
744
|
+
this.errors["confirm-password"] = "Passwords do not match", this.requestUpdate();
|
|
734
745
|
return;
|
|
735
746
|
}
|
|
736
|
-
const o = this.
|
|
747
|
+
const o = this.confirmToken || e.target.confirmation.value;
|
|
737
748
|
if (!o) {
|
|
738
|
-
this.errors.general = "Confirmation code is required
|
|
749
|
+
this.errors.general = "Confirmation code is required", this.requestUpdate();
|
|
739
750
|
return;
|
|
740
751
|
}
|
|
741
|
-
|
|
752
|
+
const i = N({
|
|
742
753
|
baseUrl: this.api
|
|
743
|
-
})
|
|
754
|
+
});
|
|
755
|
+
i.confirmResetPassword({
|
|
744
756
|
username: this.username,
|
|
745
757
|
newPassword: t,
|
|
746
758
|
confirmationCode: o
|
|
747
|
-
}).then(() =>
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
759
|
+
}).then(() => {
|
|
760
|
+
i.mintToken({ username: this.username, password: t }).then(({ token: n }) => {
|
|
761
|
+
this.dispatchEvent(new CustomEvent("login-success", {
|
|
762
|
+
detail: { token: n },
|
|
763
|
+
bubbles: !0,
|
|
764
|
+
composed: !0,
|
|
765
|
+
cancelable: !0
|
|
766
|
+
}));
|
|
767
|
+
});
|
|
768
|
+
}).catch((n) => {
|
|
769
|
+
this.errors.general = n.message || "Unable to send password reset request. Please try again later.";
|
|
755
770
|
}).finally(() => {
|
|
756
771
|
this.requestUpdate();
|
|
757
772
|
});
|
|
758
773
|
}
|
|
759
774
|
render() {
|
|
760
775
|
switch (this.stage) {
|
|
761
|
-
case
|
|
776
|
+
case _.FINISHED:
|
|
777
|
+
return p`<p>Your password has been reset.</p>`;
|
|
778
|
+
case _.CONFIRM:
|
|
762
779
|
return this.renderConfirmForm();
|
|
763
|
-
case
|
|
764
|
-
return c`<p>Your password has been reset.</p>`;
|
|
765
|
-
case g.REQUEST_SENT:
|
|
766
|
-
return c`<p>A email has been sent with instructions to finish
|
|
767
|
-
resetting your password.</p>`;
|
|
768
|
-
case g.REQUEST:
|
|
780
|
+
case _.REQUEST:
|
|
769
781
|
default:
|
|
770
782
|
return this.renderRequestForm();
|
|
771
783
|
}
|
|
772
784
|
}
|
|
773
785
|
renderRequestForm() {
|
|
774
|
-
return
|
|
786
|
+
return p`<form @submit="${this.handleSubmitRequest}">
|
|
787
|
+
<p>Enter your username or email address to request a password reset.</p>
|
|
775
788
|
<label for="username">Username/Email</label>
|
|
776
789
|
<input
|
|
777
790
|
type="text"
|
|
@@ -780,20 +793,20 @@ class Ve extends b {
|
|
|
780
793
|
required
|
|
781
794
|
/>
|
|
782
795
|
<p class="error">${this.errors.general}</p>
|
|
783
|
-
<input type="submit" value="Request
|
|
796
|
+
<input type="submit" value="Request Password Reset" />
|
|
784
797
|
</form>`;
|
|
785
798
|
}
|
|
786
799
|
renderConfirmForm() {
|
|
787
|
-
return
|
|
788
|
-
|
|
800
|
+
return p`<form @submit="${this.handleSubmitConfirm}">
|
|
801
|
+
<p>You should have received a confirmation code to reset your password.</p>
|
|
789
802
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
803
|
+
${this.confirmToken ? "" : p`<label for="confirmation">Confirmation Code</label>
|
|
804
|
+
<input
|
|
805
|
+
type="text"
|
|
806
|
+
name="confirmation"
|
|
807
|
+
placeholder="Confirmation Code"
|
|
808
|
+
required
|
|
809
|
+
/>`}
|
|
797
810
|
|
|
798
811
|
<label for="password">New Password</label>
|
|
799
812
|
<input
|
|
@@ -802,8 +815,6 @@ class Ve extends b {
|
|
|
802
815
|
placeholder="Password"
|
|
803
816
|
required
|
|
804
817
|
/>
|
|
805
|
-
${this.errors.password ? c`<p class="error">${this.errors.password}</p>` : ""}
|
|
806
|
-
|
|
807
818
|
<label for="confirm-password">Confirm Password</label>
|
|
808
819
|
<input
|
|
809
820
|
type="password"
|
|
@@ -811,27 +822,28 @@ class Ve extends b {
|
|
|
811
822
|
placeholder="Confirm Password"
|
|
812
823
|
required
|
|
813
824
|
/>
|
|
814
|
-
${this.errors["confirm-password"] ?
|
|
825
|
+
${this.errors["confirm-password"] ? p`<p class="error">${this.errors["confirm-password"]}</p>` : ""}
|
|
826
|
+
|
|
827
|
+
${this.errors.general ? p`<p class="error">${this.errors.general}</p>` : ""}
|
|
815
828
|
|
|
816
|
-
${this.errors.general ? c`<p class="error">${this.errors.general}</p>` : ""}
|
|
817
829
|
<input type="submit" value="Reset Password" />
|
|
818
830
|
</form>`;
|
|
819
831
|
}
|
|
820
832
|
}
|
|
821
|
-
|
|
833
|
+
customElements.get("auth-forgot-password-form") || window.customElements.define("auth-forgot-password-form", je);
|
|
834
|
+
class Be extends v {
|
|
822
835
|
static get properties() {
|
|
823
836
|
return {
|
|
824
837
|
api: { type: String, attribute: "api" }
|
|
825
838
|
};
|
|
826
839
|
}
|
|
827
840
|
static get styles() {
|
|
828
|
-
return
|
|
841
|
+
return J`
|
|
829
842
|
:host {
|
|
830
843
|
display: block;
|
|
831
|
-
font-family: Arial, sans-serif;
|
|
832
844
|
}
|
|
833
845
|
.login-form {
|
|
834
|
-
background-color: var(--color-gray-
|
|
846
|
+
background-color: var(--color-gray-50);
|
|
835
847
|
padding: var(--spacing-xl, 3rem);
|
|
836
848
|
border-radius: var(--radius-md, 5px);
|
|
837
849
|
box-shadow: var(--drop-shadow-md, none);
|
|
@@ -842,14 +854,14 @@ class y extends b {
|
|
|
842
854
|
margin: 5px 0 15px 0;
|
|
843
855
|
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
844
856
|
box-sizing: border-box;
|
|
845
|
-
border: 1px solid var(--color-gray-300, #
|
|
846
|
-
border-radius: var(--radius-sm,
|
|
847
|
-
color: var(--color-gray-
|
|
848
|
-
background-color: var(--color-gray-
|
|
857
|
+
border: 1px solid var(--color-gray-300, #CCC);
|
|
858
|
+
border-radius: var(--radius-sm, 3px);
|
|
859
|
+
color: var(--color-gray-700, #333);
|
|
860
|
+
background-color: var(--color-gray-100, #FFF);
|
|
849
861
|
}
|
|
850
862
|
form input[type="submit"] {
|
|
851
863
|
background-color: var(--color-primary, inherit);
|
|
852
|
-
color: var(--color-gray-
|
|
864
|
+
color: var(--color-gray-50, #fff);
|
|
853
865
|
border: none;
|
|
854
866
|
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
855
867
|
border-radius: var(--radius-dynamic, 5px);
|
|
@@ -860,15 +872,15 @@ class y extends b {
|
|
|
860
872
|
}
|
|
861
873
|
form label {
|
|
862
874
|
font-size: 14px;
|
|
863
|
-
color: var(--color-gray-
|
|
875
|
+
color: var(--color-gray-900, #333);
|
|
864
876
|
font-weight: bold;
|
|
865
877
|
margin-bottom: var(--spacing-sm, 0.5rem);
|
|
866
878
|
}
|
|
867
879
|
a.forgot {
|
|
868
880
|
color: var(--color-primary, inherit);
|
|
869
881
|
text-decoration: none;
|
|
870
|
-
font-size: 12px;
|
|
871
882
|
font-weight: bold;
|
|
883
|
+
font-size: 12px;
|
|
872
884
|
}
|
|
873
885
|
.error {
|
|
874
886
|
color: var(--color-error, red);
|
|
@@ -883,7 +895,7 @@ class y extends b {
|
|
|
883
895
|
.header .intro {
|
|
884
896
|
width: 200px;
|
|
885
897
|
margin-bottom: 0;
|
|
886
|
-
color: var(--color-gray-
|
|
898
|
+
color: var(--color-gray-300, #333);
|
|
887
899
|
}
|
|
888
900
|
.header .brand {
|
|
889
901
|
font-size: 32px;
|
|
@@ -905,474 +917,232 @@ class y extends b {
|
|
|
905
917
|
};
|
|
906
918
|
}
|
|
907
919
|
constructor() {
|
|
908
|
-
super(), this.formState =
|
|
920
|
+
super(), this.formState = this.constructor.states.DEFAULT, this.errors = [], this.isBusy = !1;
|
|
921
|
+
}
|
|
922
|
+
login({ username: e, password: t }) {
|
|
923
|
+
return N({
|
|
924
|
+
baseUrl: this.api
|
|
925
|
+
}).mintToken({ username: e, password: t });
|
|
926
|
+
}
|
|
927
|
+
emitLoginSuccess(e) {
|
|
928
|
+
this.dispatchEvent(new CustomEvent("login-success", {
|
|
929
|
+
detail: { token: e },
|
|
930
|
+
bubbles: !0,
|
|
931
|
+
composed: !0,
|
|
932
|
+
cancelable: !0
|
|
933
|
+
}));
|
|
909
934
|
}
|
|
910
|
-
|
|
935
|
+
handleSubmitLogin(e) {
|
|
911
936
|
e.preventDefault();
|
|
912
|
-
const t = e.
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
if (i && i.name === "NEW_PASSWORD_REQUIRED") {
|
|
917
|
-
this.token = o, this.username = r.username, this.password = r.password, this.setState(y.states.CHALLENGE_CHANGE_PW);
|
|
937
|
+
const t = e.currentTarget, s = new FormData(t).entries().reduce((o, [i, n]) => (o[i] = n, o), {});
|
|
938
|
+
this.isBusy = !0, this.errors = [], this.requestUpdate(), this.login(s).then(({ token: o, challenge: i }) => {
|
|
939
|
+
if ((i == null ? void 0 : i.name) === "NEW_PASSWORD_REQUIRED") {
|
|
940
|
+
this.token = o, this.username = s.username, this.password = s.password, this.setState(this.constructor.states.CHALLENGE_CHANGE_PW);
|
|
918
941
|
return;
|
|
919
942
|
}
|
|
920
|
-
this.
|
|
921
|
-
detail: { token: o }
|
|
922
|
-
}));
|
|
943
|
+
this.emitLoginSuccess(o);
|
|
923
944
|
}).catch((o) => {
|
|
924
|
-
console.
|
|
945
|
+
console.error(o), this.errors = [o.message], this.requestUpdate();
|
|
925
946
|
});
|
|
926
947
|
}
|
|
927
948
|
onSubmitChangePasswordChallenge(e) {
|
|
928
949
|
e.preventDefault();
|
|
929
|
-
const t = e.
|
|
950
|
+
const t = e.currentTarget, s = new FormData(t).entries().reduce((l, [a, d]) => (l[a] = d, l), {}), o = s.password, i = s["confirm-password"];
|
|
930
951
|
if (o !== i) {
|
|
931
|
-
this.errors = ["Passwords do not match
|
|
952
|
+
this.errors = ["Passwords do not match"], this.requestUpdate();
|
|
932
953
|
return;
|
|
933
954
|
}
|
|
934
|
-
|
|
955
|
+
N({
|
|
935
956
|
baseUrl: this.api
|
|
936
957
|
}).updatePassword({
|
|
937
958
|
token: this.token,
|
|
938
959
|
currentPassword: this.password,
|
|
939
960
|
newPassword: o
|
|
940
961
|
}).then(() => {
|
|
941
|
-
this.
|
|
942
|
-
detail: { token: this.token }
|
|
943
|
-
}));
|
|
962
|
+
this.emitLoginSuccess(this.token);
|
|
944
963
|
}).catch((l) => {
|
|
945
|
-
console.
|
|
964
|
+
console.error(l), this.errors = [l.message], this.requestUpdate();
|
|
946
965
|
});
|
|
947
966
|
}
|
|
948
967
|
setState(e) {
|
|
949
|
-
|
|
968
|
+
this.formState = e, this.isBusy = !1, this.errors = [], this.requestUpdate();
|
|
950
969
|
}
|
|
951
970
|
render() {
|
|
952
|
-
return
|
|
971
|
+
return p`<div class="login-form">
|
|
953
972
|
${this.renderHeader()}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
973
|
+
${this.formState === this.constructor.states.DEFAULT ? this.renderLoginForm() : ""}
|
|
974
|
+
${this.formState === this.constructor.states.CHALLENGE_CHANGE_PW ? this.renderChangePasswordForm() : ""}
|
|
975
|
+
${this.formState === this.constructor.states.FORGOT ? this.renderForgotPasswordForm() : ""}
|
|
957
976
|
</div>`;
|
|
958
977
|
}
|
|
959
|
-
/**
|
|
960
|
-
* TODO: accept the header as a slot
|
|
961
|
-
*/
|
|
962
978
|
renderHeader() {
|
|
963
|
-
return
|
|
964
|
-
<div class="intro">
|
|
965
|
-
|
|
966
|
-
</div>
|
|
967
|
-
<div class="brand">
|
|
968
|
-
<em>WRAL</em>.studio
|
|
969
|
-
</div>
|
|
979
|
+
return p`<div class="header">
|
|
980
|
+
<div class="intro">Welcome to</div>
|
|
981
|
+
<div class="brand"><em>WRAL</em>.studio</div>
|
|
970
982
|
</div>`;
|
|
971
983
|
}
|
|
972
984
|
renderLoginForm() {
|
|
973
|
-
return
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
<label for="password">Password</label>
|
|
984
|
-
<input
|
|
985
|
-
type="password"
|
|
986
|
-
name="password"
|
|
987
|
-
placeholder="Password"
|
|
988
|
-
required
|
|
989
|
-
/>
|
|
990
|
-
<div>
|
|
991
|
-
<a href="#" class="forgot"
|
|
992
|
-
@click=${() => {
|
|
993
|
-
this.setState(y.states.FORGOT);
|
|
994
|
-
}}
|
|
995
|
-
>Forgot password</a>
|
|
996
|
-
</div>
|
|
997
|
-
|
|
998
|
-
${this.errors ? this.errors.map((e) => c`<p class="error">${e}</p>`) : ""}
|
|
999
|
-
<input type="submit" value="Log in" @click=${this.onSubmit} />
|
|
985
|
+
return p`
|
|
986
|
+
<form @submit=${this.handleSubmitLogin}>
|
|
987
|
+
<label for="username">User</label>
|
|
988
|
+
<input
|
|
989
|
+
type="text"
|
|
990
|
+
name="username"
|
|
991
|
+
placeholder="Email or Username"
|
|
992
|
+
required
|
|
993
|
+
/>
|
|
1000
994
|
|
|
1001
|
-
</
|
|
1002
|
-
}
|
|
1003
|
-
renderForgotPasswordForm() {
|
|
1004
|
-
return c`
|
|
1005
|
-
<auth-forgot-password-form
|
|
1006
|
-
api=${this.api}>
|
|
1007
|
-
</auth-forgot-password-form>
|
|
1008
|
-
`;
|
|
1009
|
-
}
|
|
1010
|
-
renderChangePasswordForm() {
|
|
1011
|
-
return c`
|
|
1012
|
-
<p>You have logged in successfully, but you must change your password.</p>
|
|
1013
|
-
<form @submit=${this.onSubmitChangePasswordChallenge}>
|
|
1014
|
-
<input type="hidden" name="username" value="${this.username}" />
|
|
1015
|
-
<label for="password">New Password</label>
|
|
995
|
+
<label for="password">Password</label>
|
|
1016
996
|
<input
|
|
1017
997
|
type="password"
|
|
1018
998
|
name="password"
|
|
1019
999
|
placeholder="Password"
|
|
1020
1000
|
required
|
|
1021
1001
|
/>
|
|
1022
|
-
<
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1002
|
+
<div>
|
|
1003
|
+
<a href="#" class="forgot"
|
|
1004
|
+
@click=${() => {
|
|
1005
|
+
this.setState(this.constructor.states.FORGOT);
|
|
1006
|
+
}}>Forgot password</a>
|
|
1007
|
+
</div>
|
|
1008
|
+
${this.errors ? this.errors.map((e) => p`<p class="error">${e}</p>`) : ""}
|
|
1009
|
+
|
|
1010
|
+
<input type="submit" value="Log in"
|
|
1011
|
+
?disabled=${this.isBusy}
|
|
1028
1012
|
/>
|
|
1029
|
-
${this.errors ? this.errors.map((e) => c`<p class="error">${e}</p>`) : ""}
|
|
1030
|
-
<input type="submit" value="Change Password" />
|
|
1031
1013
|
</form>
|
|
1032
1014
|
`;
|
|
1033
1015
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
const e = q`
|
|
1040
|
-
.login-layout {
|
|
1041
|
-
display: flex;
|
|
1042
|
-
flex-direction: column;
|
|
1043
|
-
gap: 1rem;
|
|
1044
|
-
justify-content: center;
|
|
1045
|
-
align-items: center;
|
|
1046
|
-
min-height: 100vh;
|
|
1047
|
-
background-color: var(--color-gray-100, #f5f5f5);
|
|
1048
|
-
}
|
|
1049
|
-
.login-layout > * {
|
|
1050
|
-
max-width: 400px;
|
|
1051
|
-
}
|
|
1016
|
+
renderForgotPasswordForm() {
|
|
1017
|
+
return p`
|
|
1018
|
+
<auth-forgot-password-form
|
|
1019
|
+
api=${this.api}>
|
|
1020
|
+
</auth-forgot-password-form>
|
|
1052
1021
|
`;
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1022
|
+
}
|
|
1023
|
+
renderChangePasswordForm() {
|
|
1024
|
+
return p`
|
|
1025
|
+
<p>You have logged in successfully, but you must change your password.</p>
|
|
1026
|
+
<form @submit="${this.onSubmitChangePasswordChallenge}">
|
|
1027
|
+
<input type="hidden" name="username" value="${this.username}" />
|
|
1028
|
+
<label for="password">New Password</label>
|
|
1029
|
+
<input
|
|
1030
|
+
type="password"
|
|
1031
|
+
name="password"
|
|
1032
|
+
placeholder="Password"
|
|
1033
|
+
required
|
|
1034
|
+
/>
|
|
1035
|
+
<label for="confirm-password">Confirm Password</label>
|
|
1036
|
+
<input
|
|
1037
|
+
type="password"
|
|
1038
|
+
name="confirm-password"
|
|
1039
|
+
placeholder="Confirm Password"
|
|
1040
|
+
required
|
|
1041
|
+
/>
|
|
1042
|
+
${this.errors ? this.errors.map((e) => p`<p class="error">${e}</p>`) : ""}
|
|
1043
|
+
<input type="submit" value="Change Password" />
|
|
1044
|
+
</form>
|
|
1058
1045
|
`;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
function Qe(s) {
|
|
1062
|
-
return JSON.parse(window.atob(s.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
1063
|
-
}
|
|
1064
|
-
function Je(s, e = 300, t = Date.now()) {
|
|
1065
|
-
return Qe(s).exp * 1e3 - e < t;
|
|
1066
|
-
}
|
|
1067
|
-
function ge(s) {
|
|
1068
|
-
return (s.startsWith("/") ? s : `/${s}`).replace(/\/{2,}/g, "/").replace(new RegExp("(?<=.)\\/$"), "");
|
|
1069
|
-
}
|
|
1070
|
-
function ye(s, e, t) {
|
|
1071
|
-
const r = Ze(s, t);
|
|
1072
|
-
e.pushState(t, t.title, r), s.requestRender(t);
|
|
1046
|
+
}
|
|
1073
1047
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
return
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1048
|
+
customElements.get("auth-login-form") || customElements.define("auth-login-form", Be);
|
|
1049
|
+
function We(r, e) {
|
|
1050
|
+
return p`<auth-login-form slot="main"
|
|
1051
|
+
api=${r == null ? void 0 : r.apiBaseUrl}
|
|
1052
|
+
@login-success=${e}>
|
|
1053
|
+
</auth-login-form>`;
|
|
1080
1054
|
}
|
|
1081
|
-
function
|
|
1082
|
-
|
|
1083
|
-
return ge(`${t}/${e.path}`);
|
|
1055
|
+
function Ge({ tokenKey: r }) {
|
|
1056
|
+
return window.localStorage.getItem(r);
|
|
1084
1057
|
}
|
|
1085
|
-
function
|
|
1086
|
-
|
|
1087
|
-
return c`
|
|
1088
|
-
<h1>Auth Dashboard</h1>
|
|
1089
|
-
<ul>
|
|
1090
|
-
<li><a href="#" @click=${((o, i) => () => {
|
|
1091
|
-
ye(e, t, { path: o, title: i });
|
|
1092
|
-
})("/change-password")}>Change Password</a></li>
|
|
1093
|
-
<li><a href="#" @click=${e.handleDestroyAuth}>Logout</a></li>
|
|
1094
|
-
</ul>
|
|
1095
|
-
`;
|
|
1058
|
+
function Ve({ tokenKey: r }, e) {
|
|
1059
|
+
window.localStorage.setItem(r, e);
|
|
1096
1060
|
}
|
|
1097
|
-
function
|
|
1098
|
-
|
|
1099
|
-
<auth-change-password-form .auth=${e}></auth-change-password-form>
|
|
1100
|
-
`;
|
|
1061
|
+
function Je({ tokenKey: r }) {
|
|
1062
|
+
window.localStorage.removeItem(r);
|
|
1101
1063
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
}
|
|
1110
|
-
h1,h2,h3,h4,h5,h6,label { font-family: var(--font-heading) }
|
|
1111
|
-
label {
|
|
1112
|
-
display: block;
|
|
1113
|
-
font-size: var(--font-size-base);
|
|
1114
|
-
margin-top: var(--spacing-md, 0.5rem);
|
|
1115
|
-
}
|
|
1116
|
-
input[type="text"],
|
|
1117
|
-
input[type="password"] {
|
|
1118
|
-
width: 100%;
|
|
1119
|
-
margin: 5px 0 15px 0;
|
|
1120
|
-
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
1121
|
-
box-sizing: border-box;
|
|
1122
|
-
border: 1px solid var(--color-gray-300, #ccc);
|
|
1123
|
-
border-radius: var(--radius-sm, 5px);
|
|
1124
|
-
color: var(--color-gray-9, #333);
|
|
1125
|
-
background-color: var(--color-gray-0, transparent);
|
|
1126
|
-
}
|
|
1127
|
-
input[type="submit"] {
|
|
1128
|
-
background-color: var(--color-primary, inherit);
|
|
1129
|
-
color: var(--color-gray-0, #fff);
|
|
1130
|
-
border: none;
|
|
1131
|
-
padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
|
|
1132
|
-
border-radius: var(--radius-dynamic, 5px);
|
|
1133
|
-
width: 200px;
|
|
1134
|
-
cursor: pointer;
|
|
1135
|
-
}
|
|
1136
|
-
.error {
|
|
1137
|
-
color: var(--color-error);
|
|
1138
|
-
}
|
|
1139
|
-
`;
|
|
1140
|
-
}
|
|
1141
|
-
static get properties() {
|
|
1142
|
-
return {
|
|
1143
|
-
auth: { type: Object }
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
constructor() {
|
|
1147
|
-
super(), this.errors = {}, this.success = null;
|
|
1148
|
-
}
|
|
1149
|
-
connectedCallback() {
|
|
1150
|
-
super.connectedCallback(), G(this);
|
|
1151
|
-
}
|
|
1152
|
-
async onSubmit(e) {
|
|
1153
|
-
if (e.preventDefault(), e.target.newPassword.value !== e.target.confirmPassword.value) {
|
|
1154
|
-
this.errors.confirmPassword = "Passwords do not match", this.requestUpdate();
|
|
1155
|
-
return;
|
|
1156
|
-
}
|
|
1157
|
-
if (e.target.newPassword.value === e.target.currentPassword.value) {
|
|
1158
|
-
this.errors.newPassword = "The new password is the same as your current password.", this.requestUpdate();
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
await G(this), await x({
|
|
1162
|
-
baseUrl: this.auth.config.api
|
|
1163
|
-
}).updatePassword({
|
|
1164
|
-
currentPassword: e.target.currentPassword.value,
|
|
1165
|
-
newPassword: e.target.newPassword.value
|
|
1166
|
-
}).then(() => {
|
|
1167
|
-
this.errors = {}, this.success = "Password changed.", this.requestUpdate();
|
|
1168
|
-
}).catch((r) => {
|
|
1169
|
-
this.errors.submit = r.message, this.requestUpdate();
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
render() {
|
|
1173
|
-
return c`
|
|
1174
|
-
<h1>Change your password</h1>
|
|
1175
|
-
<p>Enter your current password and choose a new password.</p>
|
|
1176
|
-
<form @submit=${this.onSubmit}>
|
|
1177
|
-
<div class="field">
|
|
1178
|
-
<label for="currentPassword">Current Password</label>
|
|
1179
|
-
<input
|
|
1180
|
-
type="password"
|
|
1181
|
-
name="currentPassword"
|
|
1182
|
-
placeholder="Current Password"
|
|
1183
|
-
required
|
|
1184
|
-
/>
|
|
1185
|
-
${this.errors.currentPassword ? c`<p class="error">${this.errors.currentPassword}</p>` : ""}
|
|
1186
|
-
</div>
|
|
1187
|
-
<div class="field">
|
|
1188
|
-
<label for="newPassword">New Password</label>
|
|
1189
|
-
<input
|
|
1190
|
-
type="password"
|
|
1191
|
-
name="newPassword"
|
|
1192
|
-
placeholder="New Password"
|
|
1193
|
-
required
|
|
1194
|
-
/>
|
|
1195
|
-
${this.errors.newPassword ? c`<p class="error">${this.errors.newPassword}</p>` : ""}
|
|
1196
|
-
</div>
|
|
1197
|
-
<div class="field">
|
|
1198
|
-
<label for="confirmPassword">Confirm Password</label>
|
|
1199
|
-
<input
|
|
1200
|
-
type="password"
|
|
1201
|
-
name="confirmPassword"
|
|
1202
|
-
placeholder="Confirm Password"
|
|
1203
|
-
required
|
|
1204
|
-
/>
|
|
1205
|
-
${this.errors.confirmPassword ? c`<p class="error">${this.errors.confirmPassword}</p>` : ""}
|
|
1206
|
-
</div>
|
|
1207
|
-
<input type="submit" value="Change Password" />
|
|
1208
|
-
${this.errors.submit ? c`<p class="error">${this.errors.submit}</p>` : ""}
|
|
1209
|
-
${this.success ? c`<p class="success">${this.success}</p>` : ""}
|
|
1210
|
-
</form>
|
|
1211
|
-
`;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
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 }
|
|
1218
|
-
];
|
|
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);
|
|
1064
|
+
async function Qe(r) {
|
|
1065
|
+
const e = Ge(r);
|
|
1066
|
+
if (!e || e.length < 1)
|
|
1067
|
+
throw new Error("No token found");
|
|
1068
|
+
return Ke(e) ? await N({
|
|
1069
|
+
baseUrl: r.apiBaseUrl
|
|
1070
|
+
}).refreshToken({ token: e }).then(({ token: s }) => s) : e;
|
|
1223
1071
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
}
|
|
1228
|
-
`;
|
|
1229
|
-
class it extends b {
|
|
1230
|
-
static get styles() {
|
|
1231
|
-
return [ot];
|
|
1232
|
-
}
|
|
1233
|
-
static get properties() {
|
|
1234
|
-
return {
|
|
1235
|
-
state: { type: Object },
|
|
1236
|
-
auth: { type: Object }
|
|
1237
|
-
};
|
|
1238
|
-
}
|
|
1239
|
-
render() {
|
|
1240
|
-
const { state: e, auth: t } = this;
|
|
1241
|
-
return st(e, t);
|
|
1242
|
-
}
|
|
1072
|
+
function Ke(r, e = 300, t = Date.now()) {
|
|
1073
|
+
return Ye(r).exp * 1e3 - e < t;
|
|
1243
1074
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
const e = {
|
|
1247
|
-
config: s,
|
|
1248
|
-
log: (...t) => console.log("[auth]", ...t)
|
|
1249
|
-
};
|
|
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;
|
|
1075
|
+
function Ye(r) {
|
|
1076
|
+
return JSON.parse(window.atob(r.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
|
|
1251
1077
|
}
|
|
1252
|
-
function
|
|
1253
|
-
|
|
1254
|
-
[
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
handler: s.handleTokenRequest,
|
|
1260
|
-
modName: "auth"
|
|
1261
|
-
}
|
|
1078
|
+
function ot(r, e) {
|
|
1079
|
+
var n, l, a, d, h, c, m, f, y;
|
|
1080
|
+
const t = "mod-auth", s = ((a = (l = (n = e == null ? void 0 : e.element) == null ? void 0 : n.attributes) == null ? void 0 : l.debug) == null ? void 0 : a.value) || !1, o = ((c = (h = (d = e == null ? void 0 : e.element) == null ? void 0 : d.attributes) == null ? void 0 : h["force-login"]) == null ? void 0 : c.value) || !1, i = {
|
|
1081
|
+
modName: t,
|
|
1082
|
+
toolkit: r,
|
|
1083
|
+
apiBaseUrl: ((y = (f = (m = e == null ? void 0 : e.element) == null ? void 0 : m.attributes) == null ? void 0 : f.api) == null ? void 0 : y.value) || "https://api.wral.com/auth",
|
|
1084
|
+
debug: s ? (...L) => console.log("[auth]", ...L) : () => {
|
|
1262
1085
|
},
|
|
1263
|
-
{
|
|
1086
|
+
tokenKey: `${t}::token`,
|
|
1087
|
+
callbacks: [],
|
|
1088
|
+
isLoginPresent: !1
|
|
1089
|
+
};
|
|
1090
|
+
Object.entries({
|
|
1091
|
+
"auth:requestToken": Ze,
|
|
1092
|
+
"auth:destroy": Xe
|
|
1093
|
+
}).forEach(([L, pe]) => {
|
|
1094
|
+
const me = (...F) => i.debug("[action]", L, ...F);
|
|
1095
|
+
r.dispatchAction({
|
|
1264
1096
|
type: "action:register",
|
|
1265
1097
|
detail: {
|
|
1266
|
-
actionType:
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
{
|
|
1272
|
-
type: "layout:register",
|
|
1273
|
-
detail: {
|
|
1274
|
-
name: "auth:login",
|
|
1275
|
-
slots: ["main"],
|
|
1276
|
-
templateFn: Ke()
|
|
1098
|
+
actionType: L,
|
|
1099
|
+
modName: t,
|
|
1100
|
+
handler: (...F) => {
|
|
1101
|
+
me("handler", ...F), pe(i, ...F);
|
|
1102
|
+
}
|
|
1277
1103
|
}
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
|
|
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({
|
|
1285
|
-
type: "layout:slot:replace",
|
|
1104
|
+
});
|
|
1105
|
+
}), r.dispatchAction({
|
|
1106
|
+
type: "layout:register",
|
|
1286
1107
|
detail: {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
content: c`<auth-app .state=${r} .auth=${s}></auth-app>`
|
|
1108
|
+
name: `${t}::auth-layout`,
|
|
1109
|
+
templateFn: Le
|
|
1290
1110
|
}
|
|
1291
|
-
});
|
|
1111
|
+
}), o && fe(e.element);
|
|
1292
1112
|
}
|
|
1293
|
-
function
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
e.forEach((i) => {
|
|
1302
|
-
i(o);
|
|
1303
|
-
}), e = [];
|
|
1304
|
-
};
|
|
1305
|
-
return async ({ callback: o }) => {
|
|
1306
|
-
let i;
|
|
1307
|
-
try {
|
|
1308
|
-
i = await s.getFreshToken(), o(i);
|
|
1309
|
-
} catch (n) {
|
|
1310
|
-
e.push(o), t || (s.presentLoginForm({ onLogin: r }), t = !0), s.log(n);
|
|
1311
|
-
}
|
|
1312
|
-
};
|
|
1113
|
+
async function Ze(r, e) {
|
|
1114
|
+
const { callback: t } = e;
|
|
1115
|
+
let s;
|
|
1116
|
+
try {
|
|
1117
|
+
s = await Qe(r), t(s);
|
|
1118
|
+
} catch (o) {
|
|
1119
|
+
console.log("Presenting login form to get a fresh token", o), r.callbacks.push(t), r.isLoginPresent || et(r);
|
|
1120
|
+
}
|
|
1313
1121
|
}
|
|
1314
|
-
function
|
|
1315
|
-
|
|
1316
|
-
const e = Y(s);
|
|
1317
|
-
window.localStorage.removeItem(e), s.config.toolkit.dispatchAction({
|
|
1318
|
-
type: "layout:pop"
|
|
1319
|
-
});
|
|
1320
|
-
};
|
|
1122
|
+
function Xe(r) {
|
|
1123
|
+
Je(r);
|
|
1321
1124
|
}
|
|
1322
|
-
function
|
|
1323
|
-
|
|
1324
|
-
t.element.ownerDocument.defaultView.location.search
|
|
1325
|
-
).get("password_reset_confirmation"), i = (n) => {
|
|
1326
|
-
s.log("login success", { event: n });
|
|
1327
|
-
const { token: l } = n.detail;
|
|
1328
|
-
s.log("Login form dismissed", { args: [l] }), t.dispatchAction({
|
|
1329
|
-
type: "layout:pop"
|
|
1330
|
-
}), s.saveToken({ token: l }), e({ token: l });
|
|
1331
|
-
};
|
|
1332
|
-
t.dispatchAction({
|
|
1125
|
+
function et(r) {
|
|
1126
|
+
r.isLoginPresent = !0, r.toolkit.dispatchAction({
|
|
1333
1127
|
type: "layout:push",
|
|
1334
1128
|
detail: {
|
|
1335
|
-
|
|
1129
|
+
name: `${r.modName}::auth-layout`
|
|
1336
1130
|
}
|
|
1337
|
-
}),
|
|
1338
|
-
type: "layout:
|
|
1131
|
+
}), r.toolkit.dispatchAction({
|
|
1132
|
+
type: "layout:content:append",
|
|
1339
1133
|
detail: {
|
|
1340
|
-
|
|
1341
|
-
slot: "main",
|
|
1342
|
-
content: c`<auth-login-form
|
|
1343
|
-
api=${s.config.api}
|
|
1344
|
-
confirmation="${o}"
|
|
1345
|
-
@login-success=${i}>
|
|
1346
|
-
</auth-login-form>`
|
|
1134
|
+
content: We(r, tt(r))
|
|
1347
1135
|
}
|
|
1348
1136
|
});
|
|
1349
1137
|
}
|
|
1350
|
-
function
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
return window.localStorage.getItem(e);
|
|
1358
|
-
}
|
|
1359
|
-
async function pt(s) {
|
|
1360
|
-
const e = $e(s);
|
|
1361
|
-
if (!e || e.length < 1)
|
|
1362
|
-
throw new Error("No token found");
|
|
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;
|
|
1369
|
-
}
|
|
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
|
-
});
|
|
1138
|
+
function tt(r) {
|
|
1139
|
+
return (e) => {
|
|
1140
|
+
const { token: t } = e.detail;
|
|
1141
|
+
Ve(r, t), r.callbacks.forEach((s) => s(t)), r.callbacks = [], r.isLoginPresent = !1, r.toolkit.dispatchAction({
|
|
1142
|
+
type: "layout:pop"
|
|
1143
|
+
});
|
|
1144
|
+
};
|
|
1375
1145
|
}
|
|
1376
1146
|
export {
|
|
1377
|
-
|
|
1147
|
+
ot as init
|
|
1378
1148
|
};
|