@wral/studio.mods.auth 2.0.0 → 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/dist/auth.cjs.js +3 -3
- package/dist/auth.es.js +19 -19
- package/package.json +1 -1
- package/src/login-form.mjs +4 -4
package/dist/auth.cjs.js
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
font-weight: bold;
|
|
187
187
|
font-style: normal;
|
|
188
188
|
}
|
|
189
|
-
`}static get states(){return{DEFAULT:"DEFAULT",FORGOT:"FORGOT",CHALLENGE_CHANGE_PW:"CHALLENGE_CHANGE_PW"}}constructor(){super(),this.formState=this.constructor.states.DEFAULT,this.errors=[],this.isBusy=!1}login({username:e,password:t}){return N({baseUrl:this.api}).mintToken({username:e,password:t})}emitLoginSuccess(e){this.dispatchEvent(new CustomEvent("login-success",{detail:{token:e},bubbles:!0,composed:!0,cancelable:!0}))}handleSubmitLogin(e){e.preventDefault();const t=e.
|
|
189
|
+
`}static get states(){return{DEFAULT:"DEFAULT",FORGOT:"FORGOT",CHALLENGE_CHANGE_PW:"CHALLENGE_CHANGE_PW"}}constructor(){super(),this.formState=this.constructor.states.DEFAULT,this.errors=[],this.isBusy=!1}login({username:e,password:t}){return N({baseUrl:this.api}).mintToken({username:e,password:t})}emitLoginSuccess(e){this.dispatchEvent(new CustomEvent("login-success",{detail:{token:e},bubbles:!0,composed:!0,cancelable:!0}))}handleSubmitLogin(e){e.preventDefault();const t=e.currentTarget,s=new FormData(t).entries().reduce((o,[i,n])=>(o[i]=n,o),{});this.isBusy=!0,this.errors=[],this.requestUpdate(),this.login(s).then(({token:o,challenge:i})=>{if((i==null?void 0:i.name)==="NEW_PASSWORD_REQUIRED"){this.token=o,this.username=s.username,this.password=s.password,this.setState(this.constructor.states.CHALLENGE_CHANGE_PW);return}this.emitLoginSuccess(o)}).catch(o=>{console.error(o),this.errors=[o.message],this.requestUpdate()})}onSubmitChangePasswordChallenge(e){e.preventDefault();const t=e.currentTarget,s=new FormData(t).entries().reduce((l,[a,d])=>(l[a]=d,l),{}),o=s.password,i=s["confirm-password"];if(o!==i){this.errors=["Passwords do not match"],this.requestUpdate();return}N({baseUrl:this.api}).updatePassword({token:this.token,currentPassword:this.password,newPassword:o}).then(()=>{this.emitLoginSuccess(this.token)}).catch(l=>{console.error(l),this.errors=[l.message],this.requestUpdate()})}setState(e){this.formState=e,this.isBusy=!1,this.errors=[],this.requestUpdate()}render(){return p`<div class="login-form">
|
|
190
190
|
${this.renderHeader()}
|
|
191
191
|
${this.formState===this.constructor.states.DEFAULT?this.renderLoginForm():""}
|
|
192
192
|
${this.formState===this.constructor.states.CHALLENGE_CHANGE_PW?this.renderChangePasswordForm():""}
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
<div class="intro">Welcome to</div>
|
|
196
196
|
<div class="brand"><em>WRAL</em>.studio</div>
|
|
197
197
|
</div>`}renderLoginForm(){return p`
|
|
198
|
-
<form>
|
|
198
|
+
<form @submit=${this.handleSubmitLogin}>
|
|
199
199
|
<label for="username">User</label>
|
|
200
200
|
<input
|
|
201
201
|
type="text"
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
</div>
|
|
218
218
|
${this.errors?this.errors.map(e=>p`<p class="error">${e}</p>`):""}
|
|
219
219
|
|
|
220
|
-
<input type="submit" value="Log in"
|
|
220
|
+
<input type="submit" value="Log in"
|
|
221
221
|
?disabled=${this.isBusy}
|
|
222
222
|
/>
|
|
223
223
|
</form>
|
package/dist/auth.es.js
CHANGED
|
@@ -280,7 +280,7 @@ S.elementStyles = [], S.shadowRootOptions = { mode: "open" }, S[U("elementProper
|
|
|
280
280
|
* Copyright 2017 Google LLC
|
|
281
281
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
282
282
|
*/
|
|
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(""),
|
|
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
284
|
\f\r]`, x = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, te = /-->/g, se = />/g, b = RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^
|
|
285
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
286
|
function ue(r, e) {
|
|
@@ -299,13 +299,13 @@ const xe = (r, e) => {
|
|
|
299
299
|
}
|
|
300
300
|
return [ue(r, i + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
|
|
301
301
|
};
|
|
302
|
-
class
|
|
302
|
+
class O {
|
|
303
303
|
constructor({ strings: e, _$litType$: t }, s) {
|
|
304
304
|
let o;
|
|
305
305
|
this.parts = [];
|
|
306
306
|
let i = 0, n = 0;
|
|
307
307
|
const l = e.length - 1, a = this.parts, [d, h] = xe(e, t);
|
|
308
|
-
if (this.el =
|
|
308
|
+
if (this.el = O.createElement(d, s), w.currentNode = this.el.content, t === 2 || t === 3) {
|
|
309
309
|
const c = this.el.content.firstChild;
|
|
310
310
|
c.replaceWith(...c.childNodes);
|
|
311
311
|
}
|
|
@@ -313,7 +313,7 @@ class R {
|
|
|
313
313
|
if (o.nodeType === 1) {
|
|
314
314
|
if (o.hasAttributes()) for (const c of o.getAttributeNames()) if (c.endsWith(he)) {
|
|
315
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] === "@" ?
|
|
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
317
|
} else c.startsWith(g) && (a.push({ type: 6, index: i }), o.removeAttribute(c));
|
|
318
318
|
if (de.test(o.tagName)) {
|
|
319
319
|
const c = o.textContent.split(g), m = c.length - 1;
|
|
@@ -340,7 +340,7 @@ function P(r, e, t = r, s) {
|
|
|
340
340
|
var n, l;
|
|
341
341
|
if (e === C) return e;
|
|
342
342
|
let o = s !== void 0 ? (n = t._$Co) == null ? void 0 : n[s] : t._$Cl;
|
|
343
|
-
const i =
|
|
343
|
+
const i = R(e) ? void 0 : e._$litDirective$;
|
|
344
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;
|
|
345
345
|
}
|
|
346
346
|
class Ue {
|
|
@@ -360,7 +360,7 @@ class Ue {
|
|
|
360
360
|
for (; a !== void 0; ) {
|
|
361
361
|
if (n === a.index) {
|
|
362
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
|
|
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];
|
|
364
364
|
}
|
|
365
365
|
n !== (a == null ? void 0 : a.index) && (i = w.nextNode(), n++);
|
|
366
366
|
}
|
|
@@ -391,7 +391,7 @@ class H {
|
|
|
391
391
|
return this._$AB;
|
|
392
392
|
}
|
|
393
393
|
_$AI(e, t = this) {
|
|
394
|
-
e = P(this, e, t),
|
|
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);
|
|
395
395
|
}
|
|
396
396
|
O(e) {
|
|
397
397
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -400,11 +400,11 @@ class H {
|
|
|
400
400
|
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
401
401
|
}
|
|
402
402
|
_(e) {
|
|
403
|
-
this._$AH !== u &&
|
|
403
|
+
this._$AH !== u && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(A.createTextNode(e)), this._$AH = e;
|
|
404
404
|
}
|
|
405
405
|
$(e) {
|
|
406
406
|
var i;
|
|
407
|
-
const { values: t, _$litType$: s } = e, o = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el =
|
|
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);
|
|
408
408
|
if (((i = this._$AH) == null ? void 0 : i._$AD) === o) this._$AH.p(t);
|
|
409
409
|
else {
|
|
410
410
|
const n = new Ue(o, this), l = n.u(this.options);
|
|
@@ -413,7 +413,7 @@ class H {
|
|
|
413
413
|
}
|
|
414
414
|
_$AC(e) {
|
|
415
415
|
let t = ie.get(e.strings);
|
|
416
|
-
return t === void 0 && ie.set(e.strings, t = new
|
|
416
|
+
return t === void 0 && ie.set(e.strings, t = new O(e)), t;
|
|
417
417
|
}
|
|
418
418
|
k(e) {
|
|
419
419
|
Q(this._$AH) || (this._$AH = [], this._$AR());
|
|
@@ -447,11 +447,11 @@ class D {
|
|
|
447
447
|
_$AI(e, t = this, s, o) {
|
|
448
448
|
const i = this.strings;
|
|
449
449
|
let n = !1;
|
|
450
|
-
if (i === void 0) e = P(this, e, t, 0), n = !
|
|
450
|
+
if (i === void 0) e = P(this, e, t, 0), n = !R(e) || e !== this._$AH && e !== C, n && (this._$AH = e);
|
|
451
451
|
else {
|
|
452
452
|
const l = e;
|
|
453
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 = !
|
|
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;
|
|
455
455
|
}
|
|
456
456
|
n && !o && this.j(e);
|
|
457
457
|
}
|
|
@@ -475,7 +475,7 @@ class ke extends D {
|
|
|
475
475
|
this.element.toggleAttribute(this.name, !!e && e !== u);
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
class
|
|
478
|
+
class Re extends D {
|
|
479
479
|
constructor(e, t, s, o, i) {
|
|
480
480
|
super(e, t, s, o, i), this.type = 5;
|
|
481
481
|
}
|
|
@@ -489,7 +489,7 @@ class Oe extends D {
|
|
|
489
489
|
typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e);
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
class
|
|
492
|
+
class Oe {
|
|
493
493
|
constructor(e, t, s) {
|
|
494
494
|
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
|
|
495
495
|
}
|
|
@@ -501,7 +501,7 @@ class Re {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
const j = T.litHtmlPolyfillSupport;
|
|
504
|
-
j == null || j(
|
|
504
|
+
j == null || j(O, H), (T.litHtmlVersions ?? (T.litHtmlVersions = [])).push("3.2.1");
|
|
505
505
|
const Ne = (r, e, t) => {
|
|
506
506
|
const s = (t == null ? void 0 : t.renderBefore) ?? e;
|
|
507
507
|
let o = s._$litPart$;
|
|
@@ -934,7 +934,7 @@ class Be extends v {
|
|
|
934
934
|
}
|
|
935
935
|
handleSubmitLogin(e) {
|
|
936
936
|
e.preventDefault();
|
|
937
|
-
const t = e.
|
|
937
|
+
const t = e.currentTarget, s = new FormData(t).entries().reduce((o, [i, n]) => (o[i] = n, o), {});
|
|
938
938
|
this.isBusy = !0, this.errors = [], this.requestUpdate(), this.login(s).then(({ token: o, challenge: i }) => {
|
|
939
939
|
if ((i == null ? void 0 : i.name) === "NEW_PASSWORD_REQUIRED") {
|
|
940
940
|
this.token = o, this.username = s.username, this.password = s.password, this.setState(this.constructor.states.CHALLENGE_CHANGE_PW);
|
|
@@ -947,7 +947,7 @@ class Be extends v {
|
|
|
947
947
|
}
|
|
948
948
|
onSubmitChangePasswordChallenge(e) {
|
|
949
949
|
e.preventDefault();
|
|
950
|
-
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"];
|
|
951
951
|
if (o !== i) {
|
|
952
952
|
this.errors = ["Passwords do not match"], this.requestUpdate();
|
|
953
953
|
return;
|
|
@@ -983,7 +983,7 @@ class Be extends v {
|
|
|
983
983
|
}
|
|
984
984
|
renderLoginForm() {
|
|
985
985
|
return p`
|
|
986
|
-
<form>
|
|
986
|
+
<form @submit=${this.handleSubmitLogin}>
|
|
987
987
|
<label for="username">User</label>
|
|
988
988
|
<input
|
|
989
989
|
type="text"
|
|
@@ -1007,7 +1007,7 @@ class Be extends v {
|
|
|
1007
1007
|
</div>
|
|
1008
1008
|
${this.errors ? this.errors.map((e) => p`<p class="error">${e}</p>`) : ""}
|
|
1009
1009
|
|
|
1010
|
-
<input type="submit" value="Log in"
|
|
1010
|
+
<input type="submit" value="Log in"
|
|
1011
1011
|
?disabled=${this.isBusy}
|
|
1012
1012
|
/>
|
|
1013
1013
|
</form>
|
package/package.json
CHANGED
package/src/login-form.mjs
CHANGED
|
@@ -117,7 +117,7 @@ class AuthLoginForm extends LitElement {
|
|
|
117
117
|
|
|
118
118
|
handleSubmitLogin(event) {
|
|
119
119
|
event.preventDefault();
|
|
120
|
-
const formElem = event.
|
|
120
|
+
const formElem = event.currentTarget;
|
|
121
121
|
const formData = new FormData(formElem).entries().reduce((acc, [key, value]) => {
|
|
122
122
|
acc[key] = value;
|
|
123
123
|
return acc;
|
|
@@ -150,7 +150,7 @@ class AuthLoginForm extends LitElement {
|
|
|
150
150
|
|
|
151
151
|
onSubmitChangePasswordChallenge(e) {
|
|
152
152
|
e.preventDefault();
|
|
153
|
-
const formElem = e.
|
|
153
|
+
const formElem = e.currentTarget;
|
|
154
154
|
const formData = new FormData(formElem).entries().reduce((acc, [key, value]) => {
|
|
155
155
|
acc[key] = value;
|
|
156
156
|
return acc;
|
|
@@ -209,7 +209,7 @@ class AuthLoginForm extends LitElement {
|
|
|
209
209
|
|
|
210
210
|
renderLoginForm() {
|
|
211
211
|
return html`
|
|
212
|
-
<form>
|
|
212
|
+
<form @submit=${this.handleSubmitLogin}>
|
|
213
213
|
<label for="username">User</label>
|
|
214
214
|
<input
|
|
215
215
|
type="text"
|
|
@@ -234,7 +234,7 @@ class AuthLoginForm extends LitElement {
|
|
|
234
234
|
${this.errors
|
|
235
235
|
? this.errors.map(error => html`<p class="error">${error}</p>`) : ''}
|
|
236
236
|
|
|
237
|
-
<input type="submit" value="Log in"
|
|
237
|
+
<input type="submit" value="Log in"
|
|
238
238
|
?disabled=${this.isBusy}
|
|
239
239
|
/>
|
|
240
240
|
</form>
|