@wral/studio.mods.auth 2.0.2 → 2.0.3

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 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.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">
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=Array.from(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=Array.from(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():""}
package/dist/auth.es.js CHANGED
@@ -934,7 +934,7 @@ class Be extends v {
934
934
  }
935
935
  handleSubmitLogin(e) {
936
936
  e.preventDefault();
937
- const t = e.currentTarget, s = new FormData(t).entries().reduce((o, [i, n]) => (o[i] = n, o), {});
937
+ const t = e.currentTarget, s = Array.from(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.currentTarget, s = new FormData(t).entries().reduce((l, [a, d]) => (l[a] = d, l), {}), o = s.password, i = s["confirm-password"];
950
+ const t = e.currentTarget, s = Array.from(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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wral/studio.mods.auth",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Auth mod for Studio/Vellum",
5
5
  "main": "dist/auth.cjs.js",
6
6
  "module": "dist/auth.es.js",
@@ -118,10 +118,8 @@ class AuthLoginForm extends LitElement {
118
118
  handleSubmitLogin(event) {
119
119
  event.preventDefault();
120
120
  const formElem = event.currentTarget;
121
- const formData = new FormData(formElem).entries().reduce((acc, [key, value]) => {
122
- acc[key] = value;
123
- return acc;
124
- }, {});
121
+ const formData = Array.from(new FormData(formElem).entries())
122
+ .reduce((acc, [k, v]) => (acc[k] = v, acc), {});
125
123
 
126
124
  this.isBusy = true;
127
125
  this.errors = [];
@@ -151,10 +149,8 @@ class AuthLoginForm extends LitElement {
151
149
  onSubmitChangePasswordChallenge(e) {
152
150
  e.preventDefault();
153
151
  const formElem = e.currentTarget;
154
- const formData = new FormData(formElem).entries().reduce((acc, [key, value]) => {
155
- acc[key] = value;
156
- return acc;
157
- }, {});
152
+ const formData = Array.from(new FormData(formElem).entries())
153
+ .reduce((acc, [k, v]) => (acc[k] = v, acc), {});
158
154
 
159
155
  // validate password, client-side
160
156
  const password = formData['password'];