@singlebase/elements 0.7.0 → 0.8.0
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/authui-display-C2o9gApg.cjs +961 -0
- package/dist/authui-display-C2o9gApg.cjs.map +1 -0
- package/dist/{authui-display-BM_F3-5e.js → authui-display-CRUABt43.js} +1009 -862
- package/dist/authui-display-CRUABt43.js.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.js +2 -2
- package/dist/{chat-ezUmd9II.cjs → chat-BWcGH9lr.cjs} +2 -2
- package/dist/chat-BWcGH9lr.cjs.map +1 -0
- package/dist/{chat-BH_3e1jT.js → chat-t4o5FsxM.js} +5 -5
- package/dist/chat-t4o5FsxM.js.map +1 -0
- package/dist/chat.cjs +1 -1
- package/dist/chat.js +1 -1
- package/dist/elements/authui-account.d.ts +0 -1
- package/dist/elements/authui-buttons.d.ts +1 -1
- package/dist/elements/authui.d.ts +25 -1
- package/dist/elements/chat.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/messages.d.ts +34 -3
- package/dist/singlebase-elements.min.js +2197 -2021
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/{uploader-COP8PkJ6.cjs → uploader-C57vgFME.cjs} +27 -1
- package/dist/uploader-C57vgFME.cjs.map +1 -0
- package/dist/{uploader-tdMU9Gxv.js → uploader-Cz9yfzfV.js} +27 -1
- package/dist/uploader-Cz9yfzfV.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +1 -1
- package/dist/utils/auth-errors.d.ts +7 -0
- package/dist/utils/oauth.d.ts +24 -0
- package/dist/utils/password.d.ts +16 -0
- package/package.json +3 -3
- package/dist/authui-display-BM_F3-5e.js.map +0 -1
- package/dist/authui-display-CMVHTNFz.cjs +0 -956
- package/dist/authui-display-CMVHTNFz.cjs.map +0 -1
- package/dist/chat-BH_3e1jT.js.map +0 -1
- package/dist/chat-ezUmd9II.cjs.map +0 -1
- package/dist/uploader-COP8PkJ6.cjs.map +0 -1
- package/dist/uploader-tdMU9Gxv.js.map +0 -1
|
@@ -1,956 +0,0 @@
|
|
|
1
|
-
"use strict";var Xe=Object.defineProperty;var xe=o=>{throw TypeError(o)};var Ze=(o,n,t)=>n in o?Xe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var p=(o,n,t)=>Ze(o,typeof n!="symbol"?n+"":n,t),Ue=(o,n,t)=>n.has(o)||xe("Cannot "+t);var l=(o,n,t)=>(Ue(o,n,"read from private field"),t?t.call(o):n.get(o)),h=(o,n,t)=>n.has(o)?xe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(o):n.set(o,t),c=(o,n,t,e)=>(Ue(o,n,"write to private field"),e?e.call(o,t):n.set(o,t),t);const i=require("lit"),r=require("lit/decorators.js"),E=require("lit/directives/if-defined.js"),y=require("@singlebase/singlebase-sdk"),Be=require("./uploader-COP8PkJ6.cjs"),$e=require("./files-4T62wkwj.cjs"),S=require("@singlebase/core");class Re{constructor(n){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=n,n.addController(this)}bind(n){var t;n!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=n,n&&(this.state=n.getState(),this.unsubscribe=n.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var n;(n=this.unsubscribe)==null||n.call(this),this.unsubscribe=null}}const we={signInTitle:"Sign in",signUpTitle:"Create your account",forgotTitle:"Reset your password",verifyTitle:"Enter your code",otpTitle:"Sign in with a code",newPassTitle:"Choose a new password",inviteTitle:"You have been invited",signInSubEmailAndOauth:"Use your email or a connected provider.",signInSubEmailOnly:"Use your email address and password.",signInSubOauthOnly:"Continue with a connected provider.",signUpSub:"Free to start. No card required.",forgotSub:"We will email you a six-digit code to confirm it is you.",otpSub:"No password needed — we will email you a six-digit code.",inviteSub:"Set up your account to continue.",signInCta:"Sign in",signUpCta:"Create account",forgotCta:"Send code",verifyCta:"Verify code",otpCta:"Email me a code",newPassCta:"Save password",inviteCta:"Create account",continueCta:"Continue",backCta:"Back",emailMethodTitle:"Email",emailMethodTitleSignUp:"Email and password",emailMethodMeta:"Password or one-time code",emailMethodMetaSignUp:"Create with an address",emailMethodMetaOtp:"One-time code",oauthMethodTitle:"Single sign-on",oauthMethodMeta:"Google, GitHub, and more",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least 10 characters",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",currentPasswordLabel:"Current password",firstNameLabel:"First name",firstNamePlaceholder:"Ada",lastNameLabel:"Last name",lastNamePlaceholder:"Lovelace",phoneLabel:"Phone number",phonePlaceholder:"+1 (555) 000-0000",invitedEmailLabel:"Invited email",forgotLink:"Forgot?",otpInsteadLink:"Email me a one-time code instead",footTextSignIn:"New here?",footActionSignIn:"Create an account",footTextSignUp:"Already have an account?",footActionSignUp:"Sign in",resendQuestion:"Did not get it?",resendCta:"Resend code",oauthPrimaryLabel:"Continue with Google",oauthContinueWith:"Continue with",blockedTitleDisabled:"Sign-in is turned off",blockedTitleUnavailable:"Sign-in unavailable",blockedBodyDisabled:"Authentication is currently disabled for this application.",blockedBodyUnavailable:"No sign-in methods are enabled for this application.",blockedHint:"Contact the site owner if you think this is a mistake.",signOutCta:"Sign out",addPhotoLink:"Add photo",changePhotoLink:"Change",photoUploading:"Uploading…",photoUpdated:"Photo updated",editingLabel:"Editing",uploadPhotoCta:"Upload photo",replacePhotoCta:"Replace photo",photoHint:"PNG or JPG, up to 2 MB.",doneCta:"Done",cancelCta:"Cancel",editAccountCta:"Edit account",saveChangesCta:"Save changes",emailChangeHint:"We will send a verification link to the new address.",passwordSectionTitle:"Password",passwordChangedHint:"Last changed three months ago.",changePasswordCta:"Change password",updatePasswordCta:"Update password",twoFaTitle:"Two-factor authentication",twoFaHintOff:"Add a second step when signing in.",twoFaHintOn:"Enabled with an authenticator app.",twoFaScanHint:"Scan with your authenticator app, then enter the 6-digit code.",connectedTitle:"Connected accounts",connectedHint:"Sign in with any provider you connect here.",addAnotherLabel:"Add another",disconnectCta:"Disconnect",notConnectedLabel:"Not connected",deleteAccountCta:"Delete account",deleteAccountConfirmCta:"Permanently delete account",deletePanelBody:"This removes your profile, sessions and connected providers. It cannot be undone.",deleteConfirmLabel:"Type DELETE to confirm",deleteConfirmPlaceholder:"DELETE",savedNote:"Saved",passwordUpdatedNote:"Password updated",changeEmailTitle:"Email",newEmailLabel:"New email",changeEmailCta:"Send verification code",changeUsernameTitle:"Username",newUsernameLabel:"New username",changeUsernameCta:"Send verification code",genericErrorMessage:"Something went wrong. Please try again.",rateLimitedMessage:"Too many attempts. Try again in 5 minutes or reset your password.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordMinError:"Use at least 10 characters.",passwordMatchError:"Both passwords must match.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",notYetSupported:"Not yet supported",alreadySignedInTitle:"You are already signed in",alreadySignedInSub:"Continue where you left off, or sign out to use another account.",alreadySignedInSubPrefix:"Signed in as",continueHint:"Continuing takes you to your account.",consentPrefix:"By continuing you agree to our",consentJoin:"and",termsLabel:"Terms",privacyLabel:"Privacy Policy",emailUnchangedError:"That is already your email address.",emailUpdatedNote:"Email updated",changeEmailCtaShort:"Change email",changeEmailHint:"We will send a code to your current address to confirm it is you.",changeEmailConfirmHint:"Enter the code we sent, and your email becomes",changeEmailElsewhereHint:"Your email is changed below, with a verification step.",confirmChangeCta:"Confirm change",codeLabel:"Verification code",linkRequiresSignIn:"Sign in first, then link a provider.",oauthCallbackTitle:"Finishing sign-in",oauthCallbackSub:"One moment while we complete your sign-in.",oauthDenied:"Sign-in was cancelled or denied."};function je(o){return o?{...we,...o}:we}var ts=Object.defineProperty,es=Object.getOwnPropertyDescriptor,C=(o,n,t,e)=>{for(var s=es(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ts(n,t,s),s},A,k,_,O,T,x;class f extends i.LitElement{constructor(){super(...arguments);h(this,A,null);h(this,k,{});h(this,_);h(this,O);h(this,T);h(this,x);p(this,"auth",new Re(this));p(this,"appliedConfig",new Set)}get client(){return l(this,A)}set client(t){c(this,A,t)}get messages(){return l(this,k)}set messages(t){c(this,k,t)}get theme(){return l(this,_)}set theme(t){c(this,_,t)}get density(){return l(this,O)}set density(t){c(this,O,t)}get fieldStyle(){return l(this,T)}set fieldStyle(t){c(this,T,t)}get radius(){return l(this,x)}set radius(t){c(this,x,t)}get resolvedClient(){var t;return this.client?this.client:((t=S.getDefaultClient())==null?void 0:t.auth)??null}get uiConfig(){var t;return((t=this.resolvedClient)==null?void 0:t.authui)??null}get msg(){var e;const t=(e=this.uiConfig)==null?void 0:e.messages;return je(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of S.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(S.authUIAttributeFor(e))||this.appliedConfig.has(e)||(this.appliedConfig.add(e),this[e]=s))}for(const[e,s]of Object.entries(t.tokens??{}))e.startsWith("--")&&(this.style.getPropertyValue(e)||this.style.setProperty(e,s))}}isAuthenticated(){var t;return((t=this.resolvedClient)==null?void 0:t.isAuthenticated())??!1}getUser(){var t;return((t=this.resolvedClient)==null?void 0:t.getUser())??null}async refreshSession(){var t;return(t=this.resolvedClient)==null?void 0:t.refreshSession()}async logout(){var t;await((t=this.resolvedClient)==null?void 0:t.logout())}willUpdate(t){super.willUpdate(t),this.auth.bind(this.resolvedClient),this.applyUIConfig()}}A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,T=new WeakMap,x=new WeakMap,p(f,"styles",[$e.tokenDefaults,Be.sharedStyles]);C([r.property({attribute:!1})],f.prototype,"client");C([r.property({attribute:!1})],f.prototype,"messages");C([r.property({reflect:!0})],f.prototype,"theme");C([r.property({reflect:!0})],f.prototype,"density");C([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");C([r.property({reflect:!0})],f.prototype,"radius");class fe{constructor(n){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=n,n.addController(this)}hostConnected(){}load(n,t){if(t){this.settings=t;return}if(!n||n===this.client)return;this.client=n;let e=this.cache.get(n);e||(e=n.getSettings(),this.cache.set(n,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ss=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],is={load:"auth:ready",signin:"auth:signin",signup:"auth:signup",session:"auth:session","account-updated":"auth:profile-update",signout:"auth:signout",error:"auth:error",navigate:"auth:navigate"};function Le(o){return"on"+o.replace(/(^|-)([a-z])/g,(n,t,e)=>e.toUpperCase())}class as{constructor(n){p(this,"unsubscribes",[]);p(this,"client",null);this.host=n,n.addController(this)}bind(n){n!==this.client&&(this.release(),this.client=n,n&&(this.unsubscribes=ss.map(t=>n.on(t,e=>this.publish(t,e)))))}publish(n,t){const e=this.host[Le(n)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Le(n)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${n}`,s));const a=is[n];a&&this.host.dispatchEvent(new CustomEvent(a,s))}release(){this.unsubscribes.forEach(n=>n()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var ns=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,Ee=(o,n,t,e)=>{for(var s=rs(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ns(n,t,s),s},U,L,M;class me extends f{constructor(){super(...arguments);h(this,U,"idle");h(this,L,"");h(this,M,"");p(this,"abortController",null)}get phase(){return l(this,U)}set phase(t){c(this,U,t)}get formError(){return l(this,L)}set formError(t){c(this,L,t)}get noticeMessage(){return l(this,M)}set noticeMessage(t){c(this,M,t)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.abortController)==null||t.abort()}get signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}async run(t){this.phase="submitting",this.formError="";try{await t(),this.phase="success"}catch(e){if(this.isAbortError(e))return;this.phase="error",this.formError=this.describeError(e)}}isAbortError(t){return t instanceof DOMException&&t.name==="AbortError"}describeError(t){if(t instanceof y.SinglebaseAuthError){const e=y.mapErrorToHint(t.code);return e==="disable_retry_show_rate_limited"?this.msg.rateLimitedMessage:e==="generic_credentials_message"?this.msg.genericErrorMessage:this.msg.genericErrorMessage}return this.msg.genericErrorMessage}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
2
|
-
<div
|
|
3
|
-
role="status"
|
|
4
|
-
aria-live="polite"
|
|
5
|
-
style="position:absolute;width:1px;height:1px;overflow:hidden;"
|
|
6
|
-
>
|
|
7
|
-
${this.phase==="submitting"?"Submitting…":""}
|
|
8
|
-
${this.phase==="success"?"Done.":""}
|
|
9
|
-
</div>
|
|
10
|
-
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:null}
|
|
11
|
-
${this.noticeMessage?i.html`<p class="notice" role="status">${this.noticeMessage}</p>`:null}
|
|
12
|
-
`}}U=new WeakMap,L=new WeakMap,M=new WeakMap;Ee([r.state()],me.prototype,"phase");Ee([r.state()],me.prototype,"formError");Ee([r.state()],me.prototype,"noticeMessage");function Ce(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Pe(o){const n=Ce(o);if(n)return n.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(o==null?void 0:o.email)??"";return t?t[0].toUpperCase():"·"}var os=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,g=(o,n,t,e)=>{for(var s=e>1?void 0:e?ls(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&os(n,t,s),s};const hs={profile_photo:!0},cs=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var N,D,I,F,B,R,j,q,H,G,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,at,nt,rt,Me;exports.SinglebaseAccountScreen=(Me=class extends me{constructor(){super(...arguments);h(this,N,"");h(this,D,"");h(this,I,null);h(this,F,"singlebase-oauth-nonce");h(this,B,"");h(this,R,"");h(this,j,!1);h(this,q,"");h(this,H,"");h(this,G,"");h(this,V,"");h(this,K,"");h(this,Y,0);h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"");h(this,X,"");h(this,Z,"request");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,at,"");h(this,nt,"");h(this,rt,"");p(this,"settingsCtl",new fe(this));p(this,"flashTimer");p(this,"uidBase",`sb-acct-${Math.random().toString(36).slice(2,8)}`);p(this,"uploadClientFor",null);p(this,"uploadClientCache",null);p(this,"onChoosePhoto",()=>{var t;this.formError="",(t=this.renderRoot.querySelector("singlebase-uploader"))==null||t.open()});p(this,"onPhotoSelected",()=>{this.photoBusy=!0,this.toast=""});p(this,"onPhotoUploaded",async t=>{var a;const{completed:e,failed:s}=t.detail;try{e.length?(await((a=this.resolvedClient)==null?void 0:a.getAccount()),this.photoFailed="",this.toast=this.msg.photoUpdated):s.length&&(this.formError=s[0].error||this.msg.genericErrorMessage)}catch(d){this.formError=this.describeError(d)}finally{this.photoBusy=!1}});p(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return l(this,N)}set logoText(t){c(this,N,t)}get logoUrl(){return l(this,D)}set logoUrl(t){c(this,D,t)}get settings(){return l(this,I)}set settings(t){c(this,I,t)}get nonceStorageKey(){return l(this,F)}set nonceStorageKey(t){c(this,F,t)}get editMode(){return l(this,B)}set editMode(t){c(this,B,t)}get toast(){return l(this,R)}set toast(t){c(this,R,t)}get photoBusy(){return l(this,j)}set photoBusy(t){c(this,j,t)}get photoFailed(){return l(this,q)}set photoFailed(t){c(this,q,t)}get profileSaved(){return l(this,H)}set profileSaved(t){c(this,H,t)}get passSaved(){return l(this,G)}set passSaved(t){c(this,G,t)}get profileError(){return l(this,V)}set profileError(t){c(this,V,t)}get newPassError(){return l(this,K)}set newPassError(t){c(this,K,t)}get deleteStage(){return l(this,Y)}set deleteStage(t){c(this,Y,t)}get confirmText(){return l(this,W)}set confirmText(t){c(this,W,t)}get dFirst(){return l(this,z)}set dFirst(t){c(this,z,t)}get dLast(){return l(this,J)}set dLast(t){c(this,J,t)}get dPhone(){return l(this,Q)}set dPhone(t){c(this,Q,t)}get dEmail(){return l(this,X)}set dEmail(t){c(this,X,t)}get emailStep(){return l(this,Z)}set emailStep(t){c(this,Z,t)}get dNewEmail(){return l(this,tt)}set dNewEmail(t){c(this,tt,t)}get emailCode(){return l(this,et)}set emailCode(t){c(this,et,t)}get emailError(){return l(this,st)}set emailError(t){c(this,st,t)}get emailSaved(){return l(this,it)}set emailSaved(t){c(this,it,t)}get curPass(){return l(this,at)}set curPass(t){c(this,at,t)}get newPass(){return l(this,nt)}set newPass(t){c(this,nt,t)}get confirmPass(){return l(this,rt)}set confirmPass(t){c(this,rt,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings)}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.flashTimer)}flash(t,e){this[t]=e,clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this[t]=""},2600)}renderLogo(){return this.logoUrl?i.html`<img
|
|
13
|
-
part="logo"
|
|
14
|
-
src=${this.logoUrl}
|
|
15
|
-
alt=${this.logoText}
|
|
16
|
-
style="display:block;align-self:flex-start;height:var(--sb-logo-height,20px);width:auto;max-width:100%"
|
|
17
|
-
/>`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}get user(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get fullName(){return Ce(this.user)}get initials(){return Pe(this.user)}get uploadClient(){const t=this.resolvedClient;return t?(this.uploadClientFor!==t&&(this.uploadClientFor=t,this.uploadClientCache={files:y.createFilesUploadApi(t.dispatcher)}),this.uploadClientCache):null}startProfileEdit(){const t=this.user;t&&(this.dFirst=t.first_name??"",this.dLast=t.last_name??"",this.dPhone=t.phone??"",this.dEmail=t.email,this.profileError="",this.profileSaved="",this.passSaved="",this.toast="",this.editMode="profile")}async onSaveProfile(){const t=this.resolvedClient;if(t){if(!this.dFirst.trim()||!this.dLast.trim()){this.profileError="First and last name cannot be empty.";return}if(this.dPhone.replace(/\D/g,"").length<7){this.profileError=this.msg.invalidPhoneError;return}await this.run(async()=>{await t.updateAccount({first_name:this.dFirst,last_name:this.dLast,phone:this.dPhone},this.signal),this.editMode="",this.flash("profileSaved",this.msg.savedNote)})}}startPassEdit(){this.curPass="",this.newPass="",this.confirmPass="",this.newPassError="",this.passSaved="",this.profileSaved="",this.toast="",this.editMode="password"}async onChangePass(){const t=this.resolvedClient;if(t){if(!this.curPass){this.newPassError="Enter your current password.";return}if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.run(async()=>{await t.changePassword({password:this.newPass},this.signal),this.editMode="",this.curPass="",this.newPass="",this.confirmPass="",this.flash("passSaved",this.msg.passwordUpdatedNote)})}}startEmailEdit(){this.emailStep="request",this.dNewEmail="",this.emailCode="",this.emailError="",this.emailSaved="",this.toast="",this.editMode="email"}async onRequestEmailCode(){const t=this.resolvedClient;if(!(!t||!this.user)){if(!this.dNewEmail.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(this.dNewEmail.toLowerCase()===this.user.email.toLowerCase()){this.emailError=this.msg.emailUnchangedError;return}await this.run(async()=>{await t.requestCode({email:this.user.email,purpose:"email_change"},this.signal),this.emailStep="confirm",this.emailError=""})}}async onConfirmEmailChange(){const t=this.resolvedClient;if(!(!t||!this.user)){if(this.emailCode.length<6){this.emailError=this.msg.codeIncompleteError;return}await this.run(async()=>{await t.changeEmail({email:this.user.email,code:this.emailCode,new_email:this.dNewEmail},this.signal),this.editMode="",this.emailCode="",this.dNewEmail="",this.flash("emailSaved",this.msg.emailUpdatedNote)})}}renderEmailSection(){var s;const t=this.editMode!=="email",e=this.editMode!==""&&this.editMode!=="email";return i.html`
|
|
18
|
-
<div class="rule"></div>
|
|
19
|
-
<div class="section">
|
|
20
|
-
<h3 class="sec-title">${this.msg.changeEmailTitle}</h3>
|
|
21
|
-
${t?i.html`
|
|
22
|
-
<div class="between">
|
|
23
|
-
<p class="hint">${((s=this.user)==null?void 0:s.email)??""}</p>
|
|
24
|
-
<div class="btn-row-end">
|
|
25
|
-
${this.emailSaved?i.html`<span role="status" class="saved-note">${this.emailSaved}</span>`:i.nothing}
|
|
26
|
-
<button
|
|
27
|
-
type="button"
|
|
28
|
-
class="edit-link"
|
|
29
|
-
?disabled=${e}
|
|
30
|
-
@click=${this.startEmailEdit}
|
|
31
|
-
>
|
|
32
|
-
${this.msg.changeEmailCtaShort}
|
|
33
|
-
</button>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
`:this.emailStep==="request"?i.html`
|
|
37
|
-
<div class="edit-card">
|
|
38
|
-
<div class="field">
|
|
39
|
-
<label for=${this.uid("newemail")}>${this.msg.newEmailLabel}</label>
|
|
40
|
-
<input
|
|
41
|
-
id=${this.uid("newemail")}
|
|
42
|
-
type="email"
|
|
43
|
-
part="input"
|
|
44
|
-
.value=${this.dNewEmail}
|
|
45
|
-
placeholder=${this.msg.emailPlaceholder}
|
|
46
|
-
aria-invalid=${this.emailError?"true":"false"}
|
|
47
|
-
?disabled=${this.submitting}
|
|
48
|
-
@input=${a=>{this.dNewEmail=a.target.value,this.emailError=""}}
|
|
49
|
-
/>
|
|
50
|
-
<p class="hint">${this.msg.changeEmailHint}</p>
|
|
51
|
-
</div>
|
|
52
|
-
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
53
|
-
<div class="edit-actions">
|
|
54
|
-
<button
|
|
55
|
-
type="button"
|
|
56
|
-
class="primary-sm"
|
|
57
|
-
?disabled=${this.submitting}
|
|
58
|
-
@click=${this.onRequestEmailCode}
|
|
59
|
-
>
|
|
60
|
-
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
61
|
-
<span>${this.msg.changeEmailCta}</span>
|
|
62
|
-
</button>
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
class="ghost-sm"
|
|
66
|
-
@click=${()=>{this.editMode="",this.emailError=""}}
|
|
67
|
-
>
|
|
68
|
-
${this.msg.cancelCta}
|
|
69
|
-
</button>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
`:i.html`
|
|
73
|
-
<div class="edit-card">
|
|
74
|
-
<p class="hint">${this.msg.codeSentNeutral}</p>
|
|
75
|
-
<div class="field">
|
|
76
|
-
<label for=${this.uid("emailcode")}>${this.msg.codeLabel}</label>
|
|
77
|
-
<input
|
|
78
|
-
id=${this.uid("emailcode")}
|
|
79
|
-
type="text"
|
|
80
|
-
inputmode="numeric"
|
|
81
|
-
autocomplete="one-time-code"
|
|
82
|
-
part="input"
|
|
83
|
-
.value=${this.emailCode}
|
|
84
|
-
placeholder="000000"
|
|
85
|
-
aria-invalid=${this.emailError?"true":"false"}
|
|
86
|
-
?disabled=${this.submitting}
|
|
87
|
-
@input=${a=>{this.emailCode=a.target.value.replace(/\D/g,"").slice(0,6),this.emailError=""}}
|
|
88
|
-
/>
|
|
89
|
-
<p class="hint">${this.msg.changeEmailConfirmHint} ${this.dNewEmail}</p>
|
|
90
|
-
</div>
|
|
91
|
-
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
92
|
-
<div class="edit-actions">
|
|
93
|
-
<button
|
|
94
|
-
type="button"
|
|
95
|
-
class="primary-sm"
|
|
96
|
-
?disabled=${this.submitting}
|
|
97
|
-
@click=${this.onConfirmEmailChange}
|
|
98
|
-
>
|
|
99
|
-
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
100
|
-
<span>${this.msg.confirmChangeCta}</span>
|
|
101
|
-
</button>
|
|
102
|
-
<button
|
|
103
|
-
type="button"
|
|
104
|
-
class="ghost-sm"
|
|
105
|
-
@click=${()=>{this.editMode="",this.emailError=""}}
|
|
106
|
-
>
|
|
107
|
-
${this.msg.cancelCta}
|
|
108
|
-
</button>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
`}
|
|
112
|
-
</div>
|
|
113
|
-
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}async onConnectProvider(t){const e=this.resolvedClient,s=this.auth.state;!e||s.status!=="authenticated"||await this.run(async()=>{var m;const a=await e.createOAuthNonce(this.signal);(m=globalThis.sessionStorage)==null||m.setItem(this.nonceStorageKey,a);const{oauth_redirect_url:d}=await e.startOAuth({provider:t,nonce:a,intent:"link",id_token:s.session.id_token,refresh_token:s.session.refresh_token},this.signal);globalThis.location.assign(d)})}get availableProviders(){const t=this.settings??this.settingsCtl.settings;if(!t||!t.oauth_settings.enabled)return[];const e={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,s])=>s.enabled).map(([s,a])=>({id:s,name:a.provider_name,mark:e[s]??a.provider_name.slice(0,2)}))}renderIdentity(){const t=this.user,e=this.editMode!==""&&this.editMode!=="avatar",s=t!=null&&t.profile_photo&&t.profile_photo!==this.photoFailed?t.profile_photo:"";return i.html`
|
|
114
|
-
<div class="acct-nav">
|
|
115
|
-
<div class="acct-who">
|
|
116
|
-
<div class="avatar-col">
|
|
117
|
-
<div class="avatar ${s?"has-photo":""}" part="avatar">
|
|
118
|
-
${s?i.html`<img
|
|
119
|
-
src=${s}
|
|
120
|
-
alt=""
|
|
121
|
-
part="avatar-image"
|
|
122
|
-
@error=${()=>this.photoFailed=s}
|
|
123
|
-
/>`:this.initials}
|
|
124
|
-
</div>
|
|
125
|
-
<button
|
|
126
|
-
type="button"
|
|
127
|
-
class="edit-link"
|
|
128
|
-
style="font-size:12px"
|
|
129
|
-
?disabled=${this.photoBusy||e}
|
|
130
|
-
@click=${this.onChoosePhoto}
|
|
131
|
-
>
|
|
132
|
-
${this.photoBusy?this.msg.photoUploading:t!=null&&t.profile_photo?this.msg.changePhotoLink:this.msg.addPhotoLink}
|
|
133
|
-
</button>
|
|
134
|
-
<singlebase-uploader
|
|
135
|
-
style="display:none"
|
|
136
|
-
view="button"
|
|
137
|
-
max-files="1"
|
|
138
|
-
branding="false"
|
|
139
|
-
accept=${cs}
|
|
140
|
-
.client=${this.uploadClient}
|
|
141
|
-
.options=${hs}
|
|
142
|
-
@singlebase-upload-selected=${this.onPhotoSelected}
|
|
143
|
-
@singlebase-upload-complete=${this.onPhotoUploaded}
|
|
144
|
-
@singlebase-upload-error=${this.onPhotoProblem}
|
|
145
|
-
@singlebase-upload-rejected=${this.onPhotoProblem}
|
|
146
|
-
></singlebase-uploader>
|
|
147
|
-
</div>
|
|
148
|
-
<div class="acct-who-text">
|
|
149
|
-
<div class="acct-name">${this.fullName||"—"}</div>
|
|
150
|
-
<div class="acct-email">${(t==null?void 0:t.email)??""}</div>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
<button type="button" class="link-sm" ?disabled=${this.submitting} @click=${this.onSignOut}>
|
|
154
|
-
${this.msg.signOutCta}
|
|
155
|
-
</button>
|
|
156
|
-
</div>
|
|
157
|
-
`}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",a=[[this.msg.firstNameLabel,t.first_name||"—"],[this.msg.lastNameLabel,t.last_name||"—"],[this.msg.phoneLabel,t.phone||"—"],[this.msg.emailLabel,t.email||"—"]];return i.html`
|
|
158
|
-
<div class="section">
|
|
159
|
-
${e?i.html`
|
|
160
|
-
<div class="sum-list">
|
|
161
|
-
${a.map(([d,m])=>i.html`
|
|
162
|
-
<div class="sum-row">
|
|
163
|
-
<span class="sum-label">${d}</span>
|
|
164
|
-
<span class="sum-value">${m}</span>
|
|
165
|
-
</div>
|
|
166
|
-
`)}
|
|
167
|
-
</div>
|
|
168
|
-
<div class="btn-row-end">
|
|
169
|
-
${this.profileSaved?i.html`<span role="status" class="saved-note">${this.profileSaved}</span>`:i.nothing}
|
|
170
|
-
<button
|
|
171
|
-
type="button"
|
|
172
|
-
class="edit-link"
|
|
173
|
-
?disabled=${s}
|
|
174
|
-
@click=${this.startProfileEdit}
|
|
175
|
-
>
|
|
176
|
-
${this.msg.editAccountCta}
|
|
177
|
-
</button>
|
|
178
|
-
</div>
|
|
179
|
-
`:i.html`
|
|
180
|
-
<div class="edit-card">
|
|
181
|
-
<div class="two-up">
|
|
182
|
-
<div class="field">
|
|
183
|
-
<label for=${this.uid("first")}>${this.msg.firstNameLabel}</label>
|
|
184
|
-
<input
|
|
185
|
-
id=${this.uid("first")}
|
|
186
|
-
type="text"
|
|
187
|
-
part="input"
|
|
188
|
-
.value=${this.dFirst}
|
|
189
|
-
placeholder=${this.msg.firstNamePlaceholder}
|
|
190
|
-
?disabled=${this.submitting}
|
|
191
|
-
@input=${d=>{this.dFirst=d.target.value,this.profileError=""}}
|
|
192
|
-
/>
|
|
193
|
-
</div>
|
|
194
|
-
<div class="field">
|
|
195
|
-
<label for=${this.uid("last")}>${this.msg.lastNameLabel}</label>
|
|
196
|
-
<input
|
|
197
|
-
id=${this.uid("last")}
|
|
198
|
-
type="text"
|
|
199
|
-
part="input"
|
|
200
|
-
.value=${this.dLast}
|
|
201
|
-
placeholder=${this.msg.lastNamePlaceholder}
|
|
202
|
-
?disabled=${this.submitting}
|
|
203
|
-
@input=${d=>{this.dLast=d.target.value,this.profileError=""}}
|
|
204
|
-
/>
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
<div class="field">
|
|
208
|
-
<label for=${this.uid("phone")}>${this.msg.phoneLabel}</label>
|
|
209
|
-
<input
|
|
210
|
-
id=${this.uid("phone")}
|
|
211
|
-
type="tel"
|
|
212
|
-
part="input"
|
|
213
|
-
.value=${this.dPhone}
|
|
214
|
-
placeholder=${this.msg.phonePlaceholder}
|
|
215
|
-
?disabled=${this.submitting}
|
|
216
|
-
@input=${d=>{this.dPhone=d.target.value,this.profileError=""}}
|
|
217
|
-
/>
|
|
218
|
-
</div>
|
|
219
|
-
<div class="field">
|
|
220
|
-
<label for=${this.uid("email")}>${this.msg.emailLabel}</label>
|
|
221
|
-
<input
|
|
222
|
-
id=${this.uid("email")}
|
|
223
|
-
type="email"
|
|
224
|
-
part="input"
|
|
225
|
-
.value=${this.dEmail}
|
|
226
|
-
disabled
|
|
227
|
-
title=${this.msg.notYetSupported}
|
|
228
|
-
/>
|
|
229
|
-
<p class="hint">${this.msg.changeEmailElsewhereHint}</p>
|
|
230
|
-
</div>
|
|
231
|
-
${this.profileError?i.html`<p class="err">${this.profileError}</p>`:i.nothing}
|
|
232
|
-
<div class="edit-actions">
|
|
233
|
-
<button
|
|
234
|
-
type="button"
|
|
235
|
-
class="primary-sm"
|
|
236
|
-
?disabled=${this.submitting}
|
|
237
|
-
@click=${this.onSaveProfile}
|
|
238
|
-
>
|
|
239
|
-
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
240
|
-
<span>${this.msg.saveChangesCta}</span>
|
|
241
|
-
</button>
|
|
242
|
-
<button
|
|
243
|
-
type="button"
|
|
244
|
-
class="ghost-sm"
|
|
245
|
-
@click=${()=>{this.editMode="",this.profileError=""}}
|
|
246
|
-
>
|
|
247
|
-
${this.msg.cancelCta}
|
|
248
|
-
</button>
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
`}
|
|
252
|
-
</div>
|
|
253
|
-
`}renderPasswordSection(){const t=this.editMode!=="password",e=this.editMode!==""&&this.editMode!=="password";return i.html`
|
|
254
|
-
<div class="rule"></div>
|
|
255
|
-
<div class="section">
|
|
256
|
-
<h3 class="sec-title">${this.msg.passwordSectionTitle}</h3>
|
|
257
|
-
${t?i.html`
|
|
258
|
-
<div class="between">
|
|
259
|
-
<p class="hint">${this.msg.passwordChangedHint}</p>
|
|
260
|
-
<div class="btn-row-end">
|
|
261
|
-
${this.passSaved?i.html`<span role="status" class="saved-note">${this.passSaved}</span>`:i.nothing}
|
|
262
|
-
<button
|
|
263
|
-
type="button"
|
|
264
|
-
class="edit-link"
|
|
265
|
-
?disabled=${e}
|
|
266
|
-
@click=${this.startPassEdit}
|
|
267
|
-
>
|
|
268
|
-
${this.msg.changePasswordCta}
|
|
269
|
-
</button>
|
|
270
|
-
</div>
|
|
271
|
-
</div>
|
|
272
|
-
`:i.html`
|
|
273
|
-
<div class="edit-card">
|
|
274
|
-
<div class="field">
|
|
275
|
-
<label for=${this.uid("curpass")}>${this.msg.currentPasswordLabel}</label>
|
|
276
|
-
<input
|
|
277
|
-
id=${this.uid("curpass")}
|
|
278
|
-
type="password"
|
|
279
|
-
part="input"
|
|
280
|
-
.value=${this.curPass}
|
|
281
|
-
placeholder=${this.msg.passwordPlaceholder}
|
|
282
|
-
?disabled=${this.submitting}
|
|
283
|
-
@input=${s=>{this.curPass=s.target.value,this.newPassError=""}}
|
|
284
|
-
/>
|
|
285
|
-
</div>
|
|
286
|
-
<div class="field">
|
|
287
|
-
<label for=${this.uid("newpass")}>${this.msg.newPasswordLabel}</label>
|
|
288
|
-
<input
|
|
289
|
-
id=${this.uid("newpass")}
|
|
290
|
-
type="password"
|
|
291
|
-
part="input"
|
|
292
|
-
.value=${this.newPass}
|
|
293
|
-
placeholder=${this.msg.newPasswordPlaceholder}
|
|
294
|
-
aria-invalid=${this.newPassError?"true":"false"}
|
|
295
|
-
?disabled=${this.submitting}
|
|
296
|
-
@input=${s=>{this.newPass=s.target.value,this.newPassError=""}}
|
|
297
|
-
/>
|
|
298
|
-
</div>
|
|
299
|
-
<div class="field">
|
|
300
|
-
<label for=${this.uid("confirmpass")}>Confirm new password</label>
|
|
301
|
-
<input
|
|
302
|
-
id=${this.uid("confirmpass")}
|
|
303
|
-
type="password"
|
|
304
|
-
part="input"
|
|
305
|
-
.value=${this.confirmPass}
|
|
306
|
-
placeholder=${this.msg.confirmPasswordPlaceholder}
|
|
307
|
-
aria-invalid=${this.newPassError?"true":"false"}
|
|
308
|
-
?disabled=${this.submitting}
|
|
309
|
-
@input=${s=>{this.confirmPass=s.target.value,this.newPassError=""}}
|
|
310
|
-
/>
|
|
311
|
-
${this.newPassError?i.html`<p class="err">${this.newPassError}</p>`:i.nothing}
|
|
312
|
-
</div>
|
|
313
|
-
<div class="edit-actions">
|
|
314
|
-
<button
|
|
315
|
-
type="button"
|
|
316
|
-
class="primary-sm"
|
|
317
|
-
?disabled=${this.submitting}
|
|
318
|
-
@click=${this.onChangePass}
|
|
319
|
-
>
|
|
320
|
-
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
321
|
-
<span>${this.msg.updatePasswordCta}</span>
|
|
322
|
-
</button>
|
|
323
|
-
<button type="button" class="ghost-sm" @click=${()=>this.editMode=""}>
|
|
324
|
-
${this.msg.cancelCta}
|
|
325
|
-
</button>
|
|
326
|
-
</div>
|
|
327
|
-
</div>
|
|
328
|
-
`}
|
|
329
|
-
</div>
|
|
330
|
-
`}renderTwoFactorSection(){return i.html`
|
|
331
|
-
<div class="rule"></div>
|
|
332
|
-
<div class="section">
|
|
333
|
-
<div class="between">
|
|
334
|
-
<div>
|
|
335
|
-
<h3 class="sec-title">${this.msg.twoFaTitle}</h3>
|
|
336
|
-
<p class="hint">${this.msg.twoFaHintOff}</p>
|
|
337
|
-
</div>
|
|
338
|
-
<button
|
|
339
|
-
type="button"
|
|
340
|
-
class="switch"
|
|
341
|
-
aria-pressed="false"
|
|
342
|
-
aria-label=${`${this.msg.twoFaTitle} (${this.msg.notYetSupported})`}
|
|
343
|
-
disabled
|
|
344
|
-
title=${this.msg.notYetSupported}
|
|
345
|
-
>
|
|
346
|
-
<span class="knob"></span>
|
|
347
|
-
</button>
|
|
348
|
-
</div>
|
|
349
|
-
<p class="disabled-note">
|
|
350
|
-
${this.msg.notYetSupported} — enrolling a second factor is not part of the current API.
|
|
351
|
-
</p>
|
|
352
|
-
</div>
|
|
353
|
-
`}renderConnectedSection(){const t=this.availableProviders;return t.length===0?i.nothing:i.html`
|
|
354
|
-
<div class="rule"></div>
|
|
355
|
-
<div class="section">
|
|
356
|
-
<h3 class="sec-title">${this.msg.connectedTitle}</h3>
|
|
357
|
-
<p class="hint">${this.msg.connectedHint}</p>
|
|
358
|
-
<span class="sub-label">${this.msg.addAnotherLabel}</span>
|
|
359
|
-
<div class="tile-grid">
|
|
360
|
-
${t.map(e=>i.html`
|
|
361
|
-
<button
|
|
362
|
-
type="button"
|
|
363
|
-
class="tile"
|
|
364
|
-
aria-label=${`Connect ${e.name}`}
|
|
365
|
-
?disabled=${this.submitting}
|
|
366
|
-
@click=${()=>this.onConnectProvider(e.id)}
|
|
367
|
-
>
|
|
368
|
-
<span class="tile-mark">${e.mark}</span>
|
|
369
|
-
<span class="tile-name">${e.name}</span>
|
|
370
|
-
<span class="tile-plus">+</span>
|
|
371
|
-
</button>
|
|
372
|
-
`)}
|
|
373
|
-
</div>
|
|
374
|
-
<p class="disabled-note">
|
|
375
|
-
${this.msg.notYetSupported} — listing or disconnecting linked providers is not part of the
|
|
376
|
-
current API.
|
|
377
|
-
</p>
|
|
378
|
-
</div>
|
|
379
|
-
`}renderDangerSection(){return i.html`
|
|
380
|
-
<div class="rule"></div>
|
|
381
|
-
<div class="section">
|
|
382
|
-
${this.deleteStage===0?i.html`<button
|
|
383
|
-
type="button"
|
|
384
|
-
class="danger-link"
|
|
385
|
-
disabled
|
|
386
|
-
title=${this.msg.notYetSupported}
|
|
387
|
-
>
|
|
388
|
-
${this.msg.deleteAccountCta}
|
|
389
|
-
</button>`:i.nothing}
|
|
390
|
-
<p class="disabled-note">
|
|
391
|
-
${this.msg.notYetSupported} — account deletion is not part of the current API.
|
|
392
|
-
</p>
|
|
393
|
-
</div>
|
|
394
|
-
`}render(){return this.user?i.html`
|
|
395
|
-
<div class="acct-root">
|
|
396
|
-
${this.renderLogo()} ${this.renderIdentity()}
|
|
397
|
-
<div class="acct-body">
|
|
398
|
-
${this.toast?i.html`<div class="notice" role="status">${this.toast}</div>`:i.nothing}
|
|
399
|
-
${this.formError?i.html`<div class="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
400
|
-
${this.renderProfileSection()} ${this.renderEmailSection()}
|
|
401
|
-
${this.renderPasswordSection()}
|
|
402
|
-
${i.nothing}
|
|
403
|
-
${this.renderConnectedSection()}
|
|
404
|
-
${i.nothing}
|
|
405
|
-
</div>
|
|
406
|
-
</div>
|
|
407
|
-
`:i.html`<p class="disabled-note">Not signed in.</p>`}},N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,H=new WeakMap,G=new WeakMap,V=new WeakMap,K=new WeakMap,Y=new WeakMap,W=new WeakMap,z=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,at=new WeakMap,nt=new WeakMap,rt=new WeakMap,Me);g([r.property({attribute:"logo-text"})],exports.SinglebaseAccountScreen.prototype,"logoText",1);g([r.property({attribute:"logo-url"})],exports.SinglebaseAccountScreen.prototype,"logoUrl",1);g([r.property({attribute:!1})],exports.SinglebaseAccountScreen.prototype,"settings",1);g([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAccountScreen.prototype,"nonceStorageKey",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"editMode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"toast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoBusy",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoFailed",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"passSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPassError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"deleteStage",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmText",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dFirst",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dLast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dPhone",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailStep",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dNewEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailCode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"curPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmPass",1);exports.SinglebaseAccountScreen=g([r.customElement("singlebase-authui-account")],exports.SinglebaseAccountScreen);var ds=Object.defineProperty,us=Object.getOwnPropertyDescriptor,w=(o,n,t,e)=>{for(var s=e>1?void 0:e?us(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&ds(n,t,s),s},ot,lt,ht,ct,dt,ut,pt,Ne;exports.SinglebaseAuthButtons=(Ne=class extends me{constructor(){super(...arguments);h(this,ot,"signout");h(this,lt,"signin");h(this,ht,"");h(this,ct,"");h(this,dt,!1);h(this,ut,null);h(this,pt,"singlebase-oauth-nonce");p(this,"settingsCtl",new fe(this))}get type(){return l(this,ot)}set type(t){c(this,ot,t)}get intent(){return l(this,lt)}set intent(t){c(this,lt,t)}get provider(){return l(this,ht)}set provider(t){c(this,ht,t)}get providerName(){return l(this,ct)}set providerName(t){c(this,ct,t)}get embedded(){return l(this,dt)}set embedded(t){c(this,dt,t)}get settings(){return l(this,ut)}set settings(t){c(this,ut,t)}get nonceStorageKey(){return l(this,pt)}set nonceStorageKey(t){c(this,pt,t)}willUpdate(t){super.willUpdate(t),this.type==="oauth"&&this.settingsCtl.load(this.resolvedClient,this.settings)}get effectiveSettings(){return this.settings??this.settingsCtl.settings}get providers(){const t=this.effectiveSettings;if(!t||!t.oauth_settings.enabled)return[];if(!(this.intent==="signup"?t.oauth_settings.allow_signup:t.oauth_settings.allow_signin)&&this.intent!=="link")return[];const s={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,a])=>a.enabled).map(([a,d])=>({id:a,name:d.provider_name,mark:s[a]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const a=this.resolvedClient;if(!a)return;let d,m;if(s){const b=this.auth.state;if(b.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}d=b.session.id_token,m=b.session.refresh_token}await this.run(async()=>{var be;const b=await a.createOAuthNonce(this.signal);(be=globalThis.sessionStorage)==null||be.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await a.startOAuth({provider:t,nonce:b,intent:e,...s?{id_token:d,refresh_token:m}:{}},this.signal);globalThis.location.assign(v)})}renderOAuth(){const t=this.providers;if(t.length===0)return i.nothing;const[e,...s]=t;return i.html`
|
|
408
|
-
<div class="stack">
|
|
409
|
-
${this.formError?i.html`<div class="banner" part="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
410
|
-
|
|
411
|
-
<button
|
|
412
|
-
type="button"
|
|
413
|
-
class="oauth-primary"
|
|
414
|
-
part="oauth-button"
|
|
415
|
-
?disabled=${this.submitting}
|
|
416
|
-
@click=${()=>this.startOAuth(e.id,this.intent)}
|
|
417
|
-
>
|
|
418
|
-
<span class="g-mark">${e.mark}</span>
|
|
419
|
-
<span>${this.msg.oauthContinueWith} ${e.name}</span>
|
|
420
|
-
</button>
|
|
421
|
-
|
|
422
|
-
${s.length?i.html`
|
|
423
|
-
<div class="icon-row">
|
|
424
|
-
${s.map(a=>i.html`
|
|
425
|
-
<button
|
|
426
|
-
type="button"
|
|
427
|
-
class="icon-btn"
|
|
428
|
-
part="oauth-button"
|
|
429
|
-
aria-label=${`${this.msg.oauthContinueWith} ${a.name}`}
|
|
430
|
-
title=${`${this.msg.oauthContinueWith} ${a.name}`}
|
|
431
|
-
?disabled=${this.submitting}
|
|
432
|
-
@click=${()=>this.startOAuth(a.id,this.intent)}
|
|
433
|
-
>
|
|
434
|
-
<span class="tile-mark">${a.mark}</span>
|
|
435
|
-
</button>
|
|
436
|
-
`)}
|
|
437
|
-
</div>
|
|
438
|
-
`:i.nothing}
|
|
439
|
-
</div>
|
|
440
|
-
`}renderLink(){return i.html`
|
|
441
|
-
<div class="stack">
|
|
442
|
-
${this.renderStatus()}
|
|
443
|
-
<button
|
|
444
|
-
type="button"
|
|
445
|
-
class="secondary"
|
|
446
|
-
part="oauth-button"
|
|
447
|
-
?disabled=${this.submitting}
|
|
448
|
-
@click=${()=>this.startOAuth(this.provider,"link",!0)}
|
|
449
|
-
>
|
|
450
|
-
${this.submitting?i.html`<span class="spinner"></span>`:i.nothing}
|
|
451
|
-
<span>${this.msg.oauthContinueWith} ${this.providerName||this.provider}</span>
|
|
452
|
-
</button>
|
|
453
|
-
</div>
|
|
454
|
-
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}renderSignOut(){return this.embedded?i.html`<button
|
|
455
|
-
type="button"
|
|
456
|
-
class="link-sm"
|
|
457
|
-
part="button-signout"
|
|
458
|
-
?disabled=${this.submitting}
|
|
459
|
-
@click=${this.onSignOut}
|
|
460
|
-
>
|
|
461
|
-
${this.msg.signOutCta}
|
|
462
|
-
</button>`:i.html`
|
|
463
|
-
<div class="stack">
|
|
464
|
-
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:i.nothing}
|
|
465
|
-
<button
|
|
466
|
-
type="button"
|
|
467
|
-
class="link-sm"
|
|
468
|
-
part="button-signout"
|
|
469
|
-
?disabled=${this.submitting}
|
|
470
|
-
@click=${this.onSignOut}
|
|
471
|
-
>
|
|
472
|
-
${this.msg.signOutCta}
|
|
473
|
-
</button>
|
|
474
|
-
</div>
|
|
475
|
-
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,Ne);w([r.property()],exports.SinglebaseAuthButtons.prototype,"type",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);w([r.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);w([r.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);w([r.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);w([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=w([r.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var qe=Object.defineProperty,ps=Object.getOwnPropertyDescriptor,gs=(o,n,t)=>n in o?qe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,u=(o,n,t,e)=>{for(var s=e>1?void 0:e?ps(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&qe(n,t,s),s},ms=(o,n,t)=>gs(o,n+"",t);const He=["signin","signup","forgot","verify","otp","newpass","invite"],Ge=["account"],bs=[...He,...Ge,"oauth-callback"];function ye(o){return He.includes(o)}function Ve(o){return Ge.includes(o)}function Se(o){return bs.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?null:"false"};var gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,Tt,xt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Ht,Gt,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ae,ne,re,De;exports.SinglebaseAuthScreen=(De=class extends f{constructor(){super(...arguments);h(this,gt,"signin");h(this,mt,"");h(this,bt,!1);h(this,ft,null);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,!0);h(this,Et,!0);h(this,Ct,"card");h(this,Pt,"bottom");h(this,At,!1);h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,Tt,"");h(this,xt,"");h(this,Ut,!0);h(this,Lt,"");h(this,Mt,"");h(this,Nt,"");h(this,Dt,"singlebase-oauth-nonce");h(this,It,"");h(this,Ft,"");h(this,Bt,"");h(this,Rt,0);h(this,jt,"");h(this,qt,"");h(this,Ht,"");h(this,Gt,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,"");h(this,zt,"");h(this,Jt,["","","","","",""]);h(this,Qt,"signin_code");h(this,Xt,!1);h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,"");h(this,ie,"");h(this,ae,0);h(this,ne,!1);p(this,"settingsCtl",new fe(this));p(this,"bridge",new as(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,re,!1);p(this,"abortController",null);p(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});p(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return l(this,gt)}set initialScreen(t){c(this,gt,t)}get screen(){return l(this,mt)}set screen(t){c(this,mt,t)}get noAccountView(){return l(this,bt)}set noAccountView(t){c(this,bt,t)}get settings(){return l(this,ft)}set settings(t){c(this,ft,t)}get authEnabled(){return l(this,vt)}set authEnabled(t){c(this,vt,t)}get allowEmailSignin(){return l(this,wt)}set allowEmailSignin(t){c(this,wt,t)}get allowEmailSignup(){return l(this,yt)}set allowEmailSignup(t){c(this,yt,t)}get allowEmailOtp(){return l(this,St)}set allowEmailOtp(t){c(this,St,t)}get allowOauth(){return l(this,$t)}set allowOauth(t){c(this,$t,t)}get allowAccountCreation(){return l(this,Et)}set allowAccountCreation(t){c(this,Et,t)}get layout(){return l(this,Ct)}set layout(t){c(this,Ct,t)}get oauthPlacement(){return l(this,Pt)}set oauthPlacement(t){c(this,Pt,t)}get stepped(){return l(this,At)}set stepped(t){c(this,At,t)}get logoText(){return l(this,kt)}set logoText(t){c(this,kt,t)}get logoUrl(){return l(this,_t)}set logoUrl(t){c(this,_t,t)}get brandLine(){return l(this,Ot)}set brandLine(t){c(this,Ot,t)}get brandFoot(){return l(this,Tt)}set brandFoot(t){c(this,Tt,t)}get signInTitle(){return l(this,xt)}set signInTitle(t){c(this,xt,t)}get branding(){return l(this,Ut)}set branding(t){c(this,Ut,t)}get redirectUrl(){return l(this,Lt)}set redirectUrl(t){c(this,Lt,t)}get tosUrl(){return l(this,Mt)}set tosUrl(t){c(this,Mt,t)}get privacyUrl(){return l(this,Nt)}set privacyUrl(t){c(this,Nt,t)}get nonceStorageKey(){return l(this,Dt)}set nonceStorageKey(t){c(this,Dt,t)}get inviteEmail(){return l(this,It)}set inviteEmail(t){c(this,It,t)}get inviteOrg(){return l(this,Ft)}set inviteOrg(t){c(this,Ft,t)}get inviteCode(){return l(this,Bt)}set inviteCode(t){c(this,Bt,t)}get step(){return l(this,Rt)}set step(t){c(this,Rt,t)}get method(){return l(this,jt)}set method(t){c(this,jt,t)}get email(){return l(this,qt)}set email(t){c(this,qt,t)}get password(){return l(this,Ht)}set password(t){c(this,Ht,t)}get name(){return l(this,Gt)}set name(t){c(this,Gt,t)}get firstName(){return l(this,Vt)}set firstName(t){c(this,Vt,t)}get lastName(){return l(this,Kt)}set lastName(t){c(this,Kt,t)}get phone(){return l(this,Yt)}set phone(t){c(this,Yt,t)}get newPass(){return l(this,Wt)}set newPass(t){c(this,Wt,t)}get confirmPass(){return l(this,zt)}set confirmPass(t){c(this,zt,t)}get code(){return l(this,Jt)}set code(t){c(this,Jt,t)}get verifyNext(){return l(this,Qt)}set verifyNext(t){c(this,Qt,t)}get loading(){return l(this,Xt)}set loading(t){c(this,Xt,t)}get banner(){return l(this,Zt)}set banner(t){c(this,Zt,t)}get notice(){return l(this,te)}set notice(t){c(this,te,t)}get emailError(){return l(this,ee)}set emailError(t){c(this,ee,t)}get passError(){return l(this,se)}set passError(t){c(this,se,t)}get newPassError(){return l(this,ie)}set newPassError(t){c(this,ie,t)}get attempts(){return l(this,ae)}set attempts(t){c(this,ae,t)}get needsMfaCode(){return l(this,ne)}set needsMfaCode(t){c(this,ne,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings),this.bridge.bind(this.resolvedClient),this.bindGoto(this.resolvedClient)}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this.gotoUnsubscribe)==null||t.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=null,(e=this.abortController)==null||e.abort()}bindGoto(t){var a;if(t===this.gotoClient||((a=this.gotoUnsubscribe)==null||a.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:d})=>{Se(d)&&this.goto(d)}),s=t.on("signin",()=>{this.followRedirect()});this.gotoUnsubscribe=()=>{e(),s()}}goto(t){this.screen!==t&&(this.screen=t,this.step=0,this.banner="",this.notice="",this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0})))}get cfg(){const t=this.settings??this.settingsCtl.settings;if(!t)return{authEnabled:this.authEnabled,allowEmailSignin:this.allowEmailSignin,allowEmailSignup:this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp,allowOauth:this.allowOauth,mfa:!1};const e=t.auth_settings,s=e.second_factor==="email_otp";return{authEnabled:t.enabled&&e.enabled&&this.authEnabled,allowEmailSignin:e.allow_signin&&this.allowEmailSignin,allowEmailSignup:e.allow_signup&&this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp&&e.allow_signin&&!s,allowOauth:t.oauth_settings.enabled&&this.allowOauth,mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return Se(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ve(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let a=e;return a==="signup"&&!s.allowEmailSignup&&(a="signin"),(a==="forgot"||a==="newpass")&&!s.allowEmailSignin&&(a="signin"),a==="otp"&&!s.allowEmailOtp&&(a="signin"),a==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(a="otp"),a}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&ye(this.activeScreen)}get redirectTarget(){var t;return Be.resolveRedirectTarget(this.redirectUrl||this.redirectParam,(t=globalThis.location)==null?void 0:t.href,e=>console.warn(`[singlebase] ${e}`))}get redirectParam(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.get("redirect")??t.get("next")??""}followRedirect(){var e;const t=this.redirectTarget;return t?((e=globalThis.location)==null||e.assign(t),!0):!1}get isOAuthCallback(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.has("access_code")||t.has("error")}get callbackDone(){return l(this,re)}set callbackDone(t){c(this,re,t)}cleanCallbackUrl(){var s;const t=(s=globalThis.location)==null?void 0:s.href;if(!t||!globalThis.history)return;const e=new URL(t);e.searchParams.delete("access_code"),e.searchParams.delete("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var m,b;if(this.callbackDone)return;this.callbackDone=!0;const t=new URLSearchParams(((m=globalThis.location)==null?void 0:m.search)??""),e=t.get("access_code"),s=t.get("error"),a=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!a)return;const d=(b=globalThis.sessionStorage)==null?void 0:b.getItem(this.nonceStorageKey);if(this.cleanCallbackUrl(),!d){this.banner=this.msg.genericErrorMessage;return}await this.withLoading(async()=>{var v;await a.completeOAuth({access_code:e,nonce:d},this.signal()),(v=globalThis.sessionStorage)==null||v.removeItem(this.nonceStorageKey)})}renderLogo(){return this.logoUrl?i.html`<img class="logo-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}renderBrandMark(){return this.logoUrl?i.html`<img class="brand-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:i.nothing}renderBranding(){return $e.renderBranding(this.branding,"Auth")}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
476
|
-
<div class="stack">
|
|
477
|
-
<div class="head">
|
|
478
|
-
${this.renderLogo()}
|
|
479
|
-
<h2 class="title" part="title">${this.msg.oauthCallbackTitle}</h2>
|
|
480
|
-
<p class="sub">${this.msg.oauthCallbackSub}</p>
|
|
481
|
-
</div>
|
|
482
|
-
${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.html`<div class="stack" style="align-items:center;">
|
|
483
|
-
<span class="spinner" part="spinner"></span>
|
|
484
|
-
</div>`}
|
|
485
|
-
${this.banner?i.html`<button type="button" class="ghost" @click=${()=>this.goto("signin")}>
|
|
486
|
-
<span>${this.msg.backCta}</span>
|
|
487
|
-
</button>`:i.nothing}
|
|
488
|
-
</div>
|
|
489
|
-
`}setScreen(t,e={}){const s=this.screen!==t;this.screen=t,this.banner="",this.emailError="",this.passError="",Object.assign(this,e),s&&this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0}))}async withLoading(t){this.loading=!0,this.banner="";try{await t()}catch(e){this.banner=this.describeError(e)}finally{this.loading=!1}}describeError(t){if(t instanceof y.SinglebaseAuthError){if(t.code==="AUTH_RATE_LIMITED")return this.msg.rateLimitedMessage;if(t.code==="INVALID_TOKEN")return"That code is not valid. Check it and try again."}return this.msg.genericErrorMessage}get codeValue(){return this.code.join("")}async onSubmit(t){t==null||t.preventDefault();const e=this.resolvedClient;if(!e)return;const s=this.activeScreen;if(this.cfg,s==="forgot"||s==="otp"){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}const a=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:a},this.signal()),this.notice=this.msg.codeSentNeutral,this.screen="verify",this.verifyNext=s==="forgot"?"newpass":"signin_code",this.code=["","","","","",""]});return}if(s==="verify"){if(this.codeValue.length<6){this.banner=this.msg.codeIncompleteError;return}if(this.verifyNext==="newpass"){this.setScreen("newpass",{notice:""});return}await this.withLoading(async()=>{await e.signIn({email:this.email,grant_type:"code",code:this.codeValue},this.signal()),this.notice=""});return}if(s==="newpass"){if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.withLoading(async()=>{await e.resetPassword({email:this.email,code:this.codeValue,new_password:this.newPass},this.signal()),this.newPass="",this.confirmPass=""});return}if(s==="invite"){if(!this.firstName.trim()||!this.lastName.trim()){this.banner="Enter your first and last name.";return}if(this.phone.replace(/\D/g,"").length<7){this.banner=this.msg.invalidPhoneError;return}if(this.password.length<10){this.passError=this.msg.passwordMinError;return}const a=this.inviteCode||this.codeValue;if(a.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:a,password:this.password,phone:this.phone},this.signal())});return}if(this.stepped&&(s==="signup"&&this.step<2||s==="signin"&&this.step<1)){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}this.step+=1;return}if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(s==="signup"){if(this.password.length<8){this.passError="Password must be at least 8 characters.";return}const[a,...d]=this.name.trim().split(/\s+/);await this.withLoading(async()=>{const m=await e.signUp({email:this.email,password:this.password,first_name:a||this.name,last_name:d.join(" ")||"—"},this.signal()),b=y.resolveScreen({next_action:m.next_action,next_operation:m.next_operation});this.setScreen("signin",{notice:"Account created. Sign in to continue.",step:0,password:"",needsMfaCode:b==="signin_with_code"})});return}if(this.password.length<8){this.attempts+=1,this.passError="Password must be at least 8 characters.",this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"";return}await this.withLoading(async()=>{try{await e.signIn({email:this.email,password:this.password,...this.needsMfaCode?{code:this.codeValue}:{}},this.signal()),this.step=0}catch(a){if(a instanceof y.SinglebaseAuthError&&a.code==="CODE_REQUIRED"){this.needsMfaCode=!0,await e.requestCode({email:this.email,purpose:"signin"},this.signal()),this.notice=this.msg.codeSentNeutral;return}if(a instanceof y.SinglebaseAuthError&&a.code==="INVALID_CREDENTIALS"){this.attempts+=1,this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"That email and password do not match.";return}throw a}})}signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}onCodeInput(t,e){var b;const a=e.target.value.replace(/\D/g,"");if(a.length>1){this.fillCode(t,a);return}const d=a.slice(-1),m=this.code.slice();m[t]=d,this.code=m,this.banner="",d&&((b=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[t+1])==null||b.focus())}onCodePaste(t,e){var a;const s=(((a=e.clipboardData)==null?void 0:a.getData("text"))??"").replace(/\D/g,"");s&&(e.preventDefault(),this.fillCode(t,s))}fillCode(t,e){const s=this.code.slice();for(let d=0;d<e.length&&t+d<s.length;d+=1)s[t+d]=e[d];this.code=s,this.banner="";const a=Math.min(t+e.length,s.length-1);this.updateComplete.then(()=>{var m;(m=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[a])==null||m.focus()})}async onResend(){const t=this.resolvedClient;if(!t||this.loading)return;const e=this.verifyNext==="newpass"?"password_reset":"signin";await this.withLoading(async()=>{await t.requestCode({email:this.email,purpose:e},this.signal()),this.notice="New code sent.",this.code=["","","","","",""]})}goBack(){if(this.step>0&&["forgot","verify","otp","newpass"].indexOf(this.activeScreen)<0){this.step-=1,this.banner="",this.notice="";return}this.setScreen("signin",{step:0,notice:"",code:["","","","","",""]})}titleFor(t){const e=this.msg;switch(t){case"signup":return e.signUpTitle;case"forgot":return e.forgotTitle;case"verify":return e.verifyTitle;case"otp":return e.otpTitle;case"newpass":return e.newPassTitle;case"invite":return e.inviteTitle;default:return this.signInTitle||e.signInTitle}}subFor(t){const e=this.msg,s=this.cfg;switch(t){case"signup":return e.signUpSub;case"forgot":return e.forgotSub;case"verify":return`We sent a 6-digit code to ${this.email||"your inbox"}. It expires in 10 minutes.`;case"otp":return e.otpSub;case"newpass":return`Your code is confirmed. Set a new password for ${this.email||"your account"}.`;case"invite":return`${this.inviteOrg||"Acme"} invited you to join. Set up your account to continue.`;default:return!s.allowEmailSignin&&!s.allowEmailOtp?e.signInSubOauthOnly:s.allowOauth?e.signInSubEmailAndOauth:e.signInSubEmailOnly}}ctaFor(t){const e=this.msg;if(this.stepped&&(t==="signup"&&this.step<2||t==="signin"&&this.step<1))return e.continueCta;switch(t){case"signup":return e.signUpCta;case"forgot":return e.forgotCta;case"verify":return e.verifyCta;case"otp":return e.otpCta;case"newpass":return e.newPassCta;case"invite":return e.inviteCta;default:return e.signInCta}}stepPct(){if(!this.stepped)return 100;const t=this.activeScreen==="signup"?3:2;return Math.round((this.step+1)/t*100)}renderPrimary(t){return i.html`
|
|
490
|
-
<button type="submit" class="primary" part="button-primary" ?disabled=${this.loading}>
|
|
491
|
-
${this.loading?i.html`<span class="spinner" part="spinner"></span>`:i.nothing}
|
|
492
|
-
<span>${t}</span>
|
|
493
|
-
</button>
|
|
494
|
-
`}renderEmailField(t){return i.html`
|
|
495
|
-
<div class="field">
|
|
496
|
-
<label for=${t}>${this.msg.emailLabel}</label>
|
|
497
|
-
<input
|
|
498
|
-
id=${t}
|
|
499
|
-
type="email"
|
|
500
|
-
part="input"
|
|
501
|
-
.value=${this.email}
|
|
502
|
-
placeholder=${this.msg.emailPlaceholder}
|
|
503
|
-
aria-invalid=${this.emailError?"true":"false"}
|
|
504
|
-
?disabled=${this.loading}
|
|
505
|
-
@input=${e=>{this.email=e.target.value,this.emailError="",this.banner=""}}
|
|
506
|
-
/>
|
|
507
|
-
${this.emailError?i.html`<p class="err">${this.emailError}</p>`:i.nothing}
|
|
508
|
-
</div>
|
|
509
|
-
`}renderPasswordField(t,e){return i.html`
|
|
510
|
-
<div class="field">
|
|
511
|
-
<div class="label-row">
|
|
512
|
-
<label for=${t}>${this.msg.passwordLabel}</label>
|
|
513
|
-
${e?i.html`<button
|
|
514
|
-
type="button"
|
|
515
|
-
class="link-sm"
|
|
516
|
-
@click=${()=>this.setScreen("forgot",{step:0})}
|
|
517
|
-
>
|
|
518
|
-
${this.msg.forgotLink}
|
|
519
|
-
</button>`:i.nothing}
|
|
520
|
-
</div>
|
|
521
|
-
<input
|
|
522
|
-
id=${t}
|
|
523
|
-
type="password"
|
|
524
|
-
part="input"
|
|
525
|
-
.value=${this.password}
|
|
526
|
-
placeholder=${this.msg.passwordPlaceholder}
|
|
527
|
-
aria-invalid=${this.passError?"true":"false"}
|
|
528
|
-
?disabled=${this.loading}
|
|
529
|
-
@input=${s=>{this.password=s.target.value,this.passError="",this.banner=""}}
|
|
530
|
-
/>
|
|
531
|
-
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
532
|
-
</div>
|
|
533
|
-
`}renderCodeRow(t=!1){return i.html`
|
|
534
|
-
<div class=${t?"code-row-sm":"code-row"} role="group" aria-label="Verification code">
|
|
535
|
-
${this.code.map((e,s)=>i.html`
|
|
536
|
-
<input
|
|
537
|
-
type="text"
|
|
538
|
-
inputmode="numeric"
|
|
539
|
-
maxlength="1"
|
|
540
|
-
part="code-box"
|
|
541
|
-
aria-label=${`Digit ${s+1}`}
|
|
542
|
-
autocomplete=${s===0?"one-time-code":"off"}
|
|
543
|
-
.value=${e}
|
|
544
|
-
?disabled=${this.loading}
|
|
545
|
-
@input=${a=>this.onCodeInput(s,a)}
|
|
546
|
-
@paste=${a=>this.onCodePaste(s,a)}
|
|
547
|
-
/>
|
|
548
|
-
`)}
|
|
549
|
-
</div>
|
|
550
|
-
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,a=t==="signup"&&(!s||this.step===0),d=t==="signup"&&(!s||this.step===1)||t==="signin"&&(!s||this.step===0)||t==="otp",m=t==="signup"&&(!s||this.step===2)||t==="signin"&&(!s||this.step===1),b=t==="signin"&&e.allowEmailSignin&&e.allowEmailOtp&&(!s||this.step===0);return i.html`
|
|
551
|
-
${a?i.html`
|
|
552
|
-
<div class="field">
|
|
553
|
-
<label for=${this.uid("name")}>${this.msg.fullNameLabel}</label>
|
|
554
|
-
<input
|
|
555
|
-
id=${this.uid("name")}
|
|
556
|
-
type="text"
|
|
557
|
-
part="input"
|
|
558
|
-
.value=${this.name}
|
|
559
|
-
placeholder=${this.msg.fullNamePlaceholder}
|
|
560
|
-
?disabled=${this.loading}
|
|
561
|
-
@input=${v=>this.name=v.target.value}
|
|
562
|
-
/>
|
|
563
|
-
</div>
|
|
564
|
-
`:i.nothing}
|
|
565
|
-
${d?this.renderEmailField(this.uid("email")):i.nothing}
|
|
566
|
-
${m?this.renderPasswordField(this.uid("pass"),e.allowEmailSignin&&t==="signin"):i.nothing}
|
|
567
|
-
${this.needsMfaCode&&t==="signin"?i.html`
|
|
568
|
-
<div class="field">
|
|
569
|
-
<span class="label">Verification code</span>
|
|
570
|
-
${this.renderCodeRow(!0)}
|
|
571
|
-
</div>
|
|
572
|
-
`:i.nothing}
|
|
573
|
-
${this.renderPrimary(this.ctaFor(t))}
|
|
574
|
-
${b?i.html`<button
|
|
575
|
-
type="button"
|
|
576
|
-
class="edit-link"
|
|
577
|
-
@click=${()=>this.setScreen("otp",{step:0})}
|
|
578
|
-
>
|
|
579
|
-
${this.msg.otpInsteadLink}
|
|
580
|
-
</button>`:i.nothing}
|
|
581
|
-
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,a=e.allowOauth;if(!s&&!a)return i.nothing;const d=s&&a,m=s?a&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",be=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ye=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Ae=(Oe,We,ze,Je,Qe,Te)=>i.html`
|
|
582
|
-
<div class="acc-item ${Oe?"open":""} ${d?"":"bare"}" part="acc-item">
|
|
583
|
-
${d?i.html`
|
|
584
|
-
<button
|
|
585
|
-
type="button"
|
|
586
|
-
class="acc-head"
|
|
587
|
-
aria-expanded=${Oe?"true":"false"}
|
|
588
|
-
aria-controls=${this.uid(`acc-${Te}`)}
|
|
589
|
-
@click=${Qe}
|
|
590
|
-
>
|
|
591
|
-
<span class="chev" aria-hidden="true">›</span>
|
|
592
|
-
<span class="acc-title">${We}</span>
|
|
593
|
-
<span class="acc-meta">${ze}</span>
|
|
594
|
-
</button>
|
|
595
|
-
`:i.nothing}
|
|
596
|
-
<div class="acc-body" id=${this.uid(`acc-${Te}`)}>
|
|
597
|
-
<div class="acc-clip">
|
|
598
|
-
<div class="acc-inner">${Je}</div>
|
|
599
|
-
</div>
|
|
600
|
-
</div>
|
|
601
|
-
</div>
|
|
602
|
-
`,ke=s?Ae(b,be,Ye,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,_e=a?Ae(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
|
|
603
|
-
type="oauth"
|
|
604
|
-
embedded
|
|
605
|
-
theme=${E.ifDefined(this.theme)}
|
|
606
|
-
density=${E.ifDefined(this.density)}
|
|
607
|
-
field-style=${E.ifDefined(this.fieldStyle)}
|
|
608
|
-
.client=${this.resolvedClient}
|
|
609
|
-
.messages=${this.messages}
|
|
610
|
-
.settings=${this.settings??this.settingsCtl.settings}
|
|
611
|
-
intent=${t==="signup"?"signup":"signin"}
|
|
612
|
-
></singlebase-authui-buttons>`,()=>this.method=v?"":"oauth","oauth"):i.nothing;return i.html`
|
|
613
|
-
<div class="acc-wrap">
|
|
614
|
-
${this.oauthPlacement==="top"?i.html`${_e}${ke}`:i.html`${ke}${_e}`}
|
|
615
|
-
</div>
|
|
616
|
-
`}renderScreenBody(t){return this.cfg,["signin","signup","otp"].indexOf(t)>=0?this.renderAccordion(t):t==="forgot"?i.html`<div class="fields">${this.renderEmailField(this.uid("reset"))}</div>`:t==="verify"?i.html`
|
|
617
|
-
${this.renderCodeRow()}
|
|
618
|
-
<div class="resend-row">
|
|
619
|
-
<span class="hint">${this.msg.resendQuestion}</span>
|
|
620
|
-
<button type="button" class="link-sm" ?disabled=${this.loading} @click=${this.onResend}>
|
|
621
|
-
${this.msg.resendCta}
|
|
622
|
-
</button>
|
|
623
|
-
</div>
|
|
624
|
-
`:t==="newpass"?i.html`
|
|
625
|
-
<div class="fields">
|
|
626
|
-
<div class="field">
|
|
627
|
-
<label for=${this.uid("newpass")}>${this.msg.newPasswordLabel}</label>
|
|
628
|
-
<input
|
|
629
|
-
id=${this.uid("newpass")}
|
|
630
|
-
type="password"
|
|
631
|
-
part="input"
|
|
632
|
-
.value=${this.newPass}
|
|
633
|
-
placeholder=${this.msg.newPasswordPlaceholder}
|
|
634
|
-
aria-invalid=${this.newPassError?"true":"false"}
|
|
635
|
-
?disabled=${this.loading}
|
|
636
|
-
@input=${s=>{this.newPass=s.target.value,this.newPassError=""}}
|
|
637
|
-
/>
|
|
638
|
-
</div>
|
|
639
|
-
<div class="field">
|
|
640
|
-
<label for=${this.uid("confirmpass")}>${this.msg.confirmPasswordLabel}</label>
|
|
641
|
-
<input
|
|
642
|
-
id=${this.uid("confirmpass")}
|
|
643
|
-
type="password"
|
|
644
|
-
part="input"
|
|
645
|
-
.value=${this.confirmPass}
|
|
646
|
-
placeholder=${this.msg.confirmPasswordPlaceholder}
|
|
647
|
-
aria-invalid=${this.newPassError?"true":"false"}
|
|
648
|
-
?disabled=${this.loading}
|
|
649
|
-
@input=${s=>{this.confirmPass=s.target.value,this.newPassError=""}}
|
|
650
|
-
/>
|
|
651
|
-
${this.newPassError?i.html`<p class="err">${this.newPassError}</p>`:i.nothing}
|
|
652
|
-
</div>
|
|
653
|
-
</div>
|
|
654
|
-
`:t==="invite"?i.html`
|
|
655
|
-
<div class="fields">
|
|
656
|
-
<div class="invite-box">
|
|
657
|
-
<span class="invite-label">${this.msg.invitedEmailLabel}</span>
|
|
658
|
-
<span class="invite-email">${this.inviteEmail}</span>
|
|
659
|
-
</div>
|
|
660
|
-
${this.inviteCode?i.nothing:i.html`<div class="field">
|
|
661
|
-
<span class="label">Invite code</span>
|
|
662
|
-
${this.renderCodeRow(!0)}
|
|
663
|
-
</div>`}
|
|
664
|
-
<div class="two-up">
|
|
665
|
-
<div class="field">
|
|
666
|
-
<label for=${this.uid("first")}>${this.msg.firstNameLabel}</label>
|
|
667
|
-
<input
|
|
668
|
-
id=${this.uid("first")}
|
|
669
|
-
type="text"
|
|
670
|
-
part="input"
|
|
671
|
-
.value=${this.firstName}
|
|
672
|
-
placeholder=${this.msg.firstNamePlaceholder}
|
|
673
|
-
?disabled=${this.loading}
|
|
674
|
-
@input=${s=>this.firstName=s.target.value}
|
|
675
|
-
/>
|
|
676
|
-
</div>
|
|
677
|
-
<div class="field">
|
|
678
|
-
<label for=${this.uid("last")}>${this.msg.lastNameLabel}</label>
|
|
679
|
-
<input
|
|
680
|
-
id=${this.uid("last")}
|
|
681
|
-
type="text"
|
|
682
|
-
part="input"
|
|
683
|
-
.value=${this.lastName}
|
|
684
|
-
placeholder=${this.msg.lastNamePlaceholder}
|
|
685
|
-
?disabled=${this.loading}
|
|
686
|
-
@input=${s=>this.lastName=s.target.value}
|
|
687
|
-
/>
|
|
688
|
-
</div>
|
|
689
|
-
</div>
|
|
690
|
-
<div class="field">
|
|
691
|
-
<label for=${this.uid("phone")}>${this.msg.phoneLabel}</label>
|
|
692
|
-
<input
|
|
693
|
-
id=${this.uid("phone")}
|
|
694
|
-
type="tel"
|
|
695
|
-
part="input"
|
|
696
|
-
.value=${this.phone}
|
|
697
|
-
placeholder=${this.msg.phonePlaceholder}
|
|
698
|
-
?disabled=${this.loading}
|
|
699
|
-
@input=${s=>this.phone=s.target.value}
|
|
700
|
-
/>
|
|
701
|
-
</div>
|
|
702
|
-
<div class="field">
|
|
703
|
-
<label for=${this.uid("invitepass")}>${this.msg.passwordLabel}</label>
|
|
704
|
-
<input
|
|
705
|
-
id=${this.uid("invitepass")}
|
|
706
|
-
type="password"
|
|
707
|
-
part="input"
|
|
708
|
-
.value=${this.password}
|
|
709
|
-
placeholder=${this.msg.newPasswordPlaceholder}
|
|
710
|
-
aria-invalid=${this.passError?"true":"false"}
|
|
711
|
-
?disabled=${this.loading}
|
|
712
|
-
@input=${s=>{this.password=s.target.value,this.passError=""}}
|
|
713
|
-
/>
|
|
714
|
-
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
715
|
-
</div>
|
|
716
|
-
</div>
|
|
717
|
-
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,a=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,d=t==="signin"&&e.allowEmailSignup||t==="signup"&&e.allowEmailSignin,m=this.stepped&&(t==="signin"||t==="signup");return i.html`
|
|
718
|
-
<form class="stack" @submit=${this.onSubmit} novalidate>
|
|
719
|
-
<div class="head">
|
|
720
|
-
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
721
|
-
<h2 class="title" part="title">${this.titleFor(t)}</h2>
|
|
722
|
-
<p class="sub">${this.subFor(t)}</p>
|
|
723
|
-
</div>
|
|
724
|
-
|
|
725
|
-
${m?i.html`<div class="step-bar">
|
|
726
|
-
<div class="step-fill" style="width:${this.stepPct()}%"></div>
|
|
727
|
-
</div>`:i.nothing}
|
|
728
|
-
${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.nothing}
|
|
729
|
-
${this.notice?i.html`<div class="notice" part="notice" role="status">${this.notice}</div>`:i.nothing}
|
|
730
|
-
${this.renderScreenBody(t)}
|
|
731
|
-
${s||a?i.html`
|
|
732
|
-
<div class="actions">
|
|
733
|
-
${s?this.renderPrimary(this.ctaFor(t)):i.nothing}
|
|
734
|
-
${a?i.html`<button type="button" class="ghost" @click=${this.goBack}>
|
|
735
|
-
${this.msg.backCta}
|
|
736
|
-
</button>`:i.nothing}
|
|
737
|
-
</div>
|
|
738
|
-
`:i.nothing}
|
|
739
|
-
${d?i.html`
|
|
740
|
-
<p class="foot">
|
|
741
|
-
<span
|
|
742
|
-
>${t==="signup"?this.msg.footTextSignUp:this.msg.footTextSignIn}</span
|
|
743
|
-
>
|
|
744
|
-
<button
|
|
745
|
-
type="button"
|
|
746
|
-
class="link"
|
|
747
|
-
@click=${()=>this.setScreen(t==="signup"?"signin":"signup",{step:0,notice:""})}
|
|
748
|
-
>
|
|
749
|
-
${t==="signup"?this.msg.footActionSignUp:this.msg.footActionSignIn}
|
|
750
|
-
</button>
|
|
751
|
-
</p>
|
|
752
|
-
`:i.nothing}
|
|
753
|
-
${this.renderConsent()}
|
|
754
|
-
|
|
755
|
-
<span class="sr-only" role="status" aria-live="polite">
|
|
756
|
-
${this.loading?"Submitting…":""}
|
|
757
|
-
</span>
|
|
758
|
-
</form>
|
|
759
|
-
`}renderBlocked(){const e=!this.cfg.authEnabled;return i.html`
|
|
760
|
-
<div class="stack">
|
|
761
|
-
<div class="head">
|
|
762
|
-
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
763
|
-
<h2 class="title" part="title">
|
|
764
|
-
${e?this.msg.blockedTitleDisabled:this.msg.blockedTitleUnavailable}
|
|
765
|
-
</h2>
|
|
766
|
-
<p class="sub">
|
|
767
|
-
${e?this.msg.blockedBodyDisabled:this.msg.blockedBodyUnavailable}
|
|
768
|
-
</p>
|
|
769
|
-
</div>
|
|
770
|
-
<div class="notice" part="notice" role="status">${this.msg.blockedHint}</div>
|
|
771
|
-
</div>
|
|
772
|
-
`}renderSignedIn(){const t=this.auth.state.status==="authenticated"?this.auth.state.user:null,e=this.redirectTarget;return i.html`
|
|
773
|
-
<div class="stack">
|
|
774
|
-
<div class="head">
|
|
775
|
-
${this.renderLogo()}
|
|
776
|
-
<h2 class="title" part="title">${this.msg.alreadySignedInTitle}</h2>
|
|
777
|
-
<p class="sub">
|
|
778
|
-
${t!=null&&t.email?`${this.msg.alreadySignedInSubPrefix} ${t.email}.`:this.msg.alreadySignedInSub}
|
|
779
|
-
</p>
|
|
780
|
-
</div>
|
|
781
|
-
|
|
782
|
-
<div class="actions">
|
|
783
|
-
<button type="button" class="primary" part="button-primary" @click=${this.onContinue}>
|
|
784
|
-
<span>${this.msg.continueCta}</span>
|
|
785
|
-
</button>
|
|
786
|
-
<button type="button" class="ghost" @click=${this.onInterstitialSignOut}>
|
|
787
|
-
<span>${this.msg.signOutCta}</span>
|
|
788
|
-
</button>
|
|
789
|
-
</div>
|
|
790
|
-
|
|
791
|
-
${e?i.nothing:i.html`<p class="hint">${this.msg.continueHint}</p>`}
|
|
792
|
-
</div>
|
|
793
|
-
`}renderConsent(){if(!this.tosUrl&&!this.privacyUrl)return i.nothing;const t=this.tosUrl?i.html`<a class="link-sm" href=${this.tosUrl} target="_blank" rel="noopener noreferrer"
|
|
794
|
-
>${this.msg.termsLabel}</a
|
|
795
|
-
>`:i.nothing,e=this.privacyUrl?i.html`<a class="link-sm" href=${this.privacyUrl} target="_blank" rel="noopener noreferrer"
|
|
796
|
-
>${this.msg.privacyLabel}</a
|
|
797
|
-
>`:i.nothing;return i.html`
|
|
798
|
-
<p class="hint" part="consent">
|
|
799
|
-
${this.msg.consentPrefix}
|
|
800
|
-
${t}${this.tosUrl&&this.privacyUrl?i.html` ${this.msg.consentJoin} `:i.nothing}${e}.
|
|
801
|
-
</p>
|
|
802
|
-
`}render(){const t=this.activeScreen;if(t==="oauth-callback")return this.handleOAuthCallback(),this.panel(this.renderOAuthCallback());if(t==="account")return this.noAccountView?i.nothing:this.panel(i.html`
|
|
803
|
-
<singlebase-authui-account
|
|
804
|
-
theme=${E.ifDefined(this.theme)}
|
|
805
|
-
density=${E.ifDefined(this.density)}
|
|
806
|
-
field-style=${E.ifDefined(this.fieldStyle)}
|
|
807
|
-
.client=${this.resolvedClient}
|
|
808
|
-
.messages=${this.messages}
|
|
809
|
-
logo-text=${this.logoText}
|
|
810
|
-
logo-url=${this.logoUrl}
|
|
811
|
-
></singlebase-authui-account>
|
|
812
|
-
`);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,a=!e.authEnabled||s&&ye(t);return i.html`
|
|
813
|
-
${this.layout==="split"?i.html`
|
|
814
|
-
<div class="brand-panel">
|
|
815
|
-
${this.renderBrandMark()}
|
|
816
|
-
${this.brandLine?i.html`<div class="brand-copy">${this.brandLine}</div>`:i.nothing}
|
|
817
|
-
${this.brandFoot?i.html`<div class="brand-foot">${this.brandFoot}</div>`:i.nothing}
|
|
818
|
-
</div>
|
|
819
|
-
`:i.nothing}
|
|
820
|
-
${this.panel(a?this.renderBlocked():this.renderGuest(t))}
|
|
821
|
-
`}},gt=new WeakMap,mt=new WeakMap,bt=new WeakMap,ft=new WeakMap,vt=new WeakMap,wt=new WeakMap,yt=new WeakMap,St=new WeakMap,$t=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,At=new WeakMap,kt=new WeakMap,_t=new WeakMap,Ot=new WeakMap,Tt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Dt=new WeakMap,It=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Rt=new WeakMap,jt=new WeakMap,qt=new WeakMap,Ht=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,ae=new WeakMap,ne=new WeakMap,re=new WeakMap,De);ms(exports.SinglebaseAuthScreen,"styles",[...f.styles,$e.brandingStyles,i.css`
|
|
822
|
-
/* the mock's root */
|
|
823
|
-
:host {
|
|
824
|
-
display: flex;
|
|
825
|
-
width: 100%;
|
|
826
|
-
box-sizing: border-box;
|
|
827
|
-
background: var(--sb-surface, #ffffff);
|
|
828
|
-
color: var(--sb-ink, #16181a);
|
|
829
|
-
border: 1px solid var(--sb-border, #e4e6e9);
|
|
830
|
-
border-radius: calc((var(--sb-radius, 4px) + 4px) * var(--sb-radius-scale, 1));
|
|
831
|
-
overflow: hidden;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
.brand-panel {
|
|
835
|
-
flex: 0 0 40%;
|
|
836
|
-
display: flex;
|
|
837
|
-
flex-direction: column;
|
|
838
|
-
justify-content: space-between;
|
|
839
|
-
gap: 24px;
|
|
840
|
-
padding: var(--sb-pad, 20px);
|
|
841
|
-
background: var(--sb-surface-alt, #fafafa);
|
|
842
|
-
border-right: 1px solid var(--sb-border, #e4e6e9);
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/* A flex column would stretch an image to full width and wreck its
|
|
846
|
-
aspect ratio, so both logos opt out of the cross-axis stretch. */
|
|
847
|
-
.logo-img {
|
|
848
|
-
display: block;
|
|
849
|
-
align-self: flex-start;
|
|
850
|
-
height: var(--sb-logo-height, 20px);
|
|
851
|
-
width: auto;
|
|
852
|
-
max-width: 100%;
|
|
853
|
-
margin-bottom: 6px;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
.brand-img {
|
|
857
|
-
display: block;
|
|
858
|
-
align-self: flex-start;
|
|
859
|
-
height: var(--sb-brand-logo-height, 28px);
|
|
860
|
-
width: auto;
|
|
861
|
-
max-width: 100%;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
.brand-mark {
|
|
865
|
-
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
866
|
-
font-size: 13px;
|
|
867
|
-
letter-spacing: 0.08em;
|
|
868
|
-
text-transform: uppercase;
|
|
869
|
-
color: var(--sb-ink, #16181a);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
.brand-copy {
|
|
873
|
-
font-size: 20px;
|
|
874
|
-
line-height: 1.35;
|
|
875
|
-
letter-spacing: -0.01em;
|
|
876
|
-
color: var(--sb-ink, #16181a);
|
|
877
|
-
text-wrap: pretty;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
.brand-foot {
|
|
881
|
-
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
882
|
-
font-size: 11px;
|
|
883
|
-
color: var(--sb-muted-ink, #61666c);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
.branding {
|
|
887
|
-
margin-top: 18px;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
/* the mock's panel */
|
|
891
|
-
.panel {
|
|
892
|
-
flex: 1;
|
|
893
|
-
min-width: 0;
|
|
894
|
-
padding: var(--sb-pad, 20px);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
@media (max-width: 520px) {
|
|
898
|
-
:host {
|
|
899
|
-
flex-direction: column;
|
|
900
|
-
}
|
|
901
|
-
.brand-panel {
|
|
902
|
-
flex: 0 0 auto;
|
|
903
|
-
border-right: none;
|
|
904
|
-
border-bottom: 1px solid var(--sb-border, #e4e6e9);
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
`]);u([r.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([r.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([r.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([r.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([r.property({converter:$,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([r.property({converter:$,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([r.property({converter:$,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([r.property({converter:$,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([r.property({converter:$,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([r.property({converter:$,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([r.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([r.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([r.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([r.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([r.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([r.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([r.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([r.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([r.property({converter:$,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([r.property({attribute:"redirect-url"})],exports.SinglebaseAuthScreen.prototype,"redirectUrl",1);u([r.property({attribute:"tos-url"})],exports.SinglebaseAuthScreen.prototype,"tosUrl",1);u([r.property({attribute:"privacy-url"})],exports.SinglebaseAuthScreen.prototype,"privacyUrl",1);u([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthScreen.prototype,"nonceStorageKey",1);u([r.property({attribute:"invite-email"})],exports.SinglebaseAuthScreen.prototype,"inviteEmail",1);u([r.property({attribute:"invite-org"})],exports.SinglebaseAuthScreen.prototype,"inviteOrg",1);u([r.property({attribute:"invite-code"})],exports.SinglebaseAuthScreen.prototype,"inviteCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"step",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"method",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"email",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"password",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"name",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"firstName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"lastName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"phone",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"confirmPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"code",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"verifyNext",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"loading",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"banner",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"notice",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"emailError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"passError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPassError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"attempts",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"needsMfaCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"callbackDone",1);exports.SinglebaseAuthScreen=u([r.customElement("singlebase-authui")],exports.SinglebaseAuthScreen);var fs=Object.defineProperty,vs=Object.getOwnPropertyDescriptor,ve=(o,n,t,e)=>{for(var s=e>1?void 0:e?vs(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&fs(n,t,s),s};const ws=["loading","authenticated","unauthenticated"];var oe,le,he,Ie;exports.SinglebaseAuthGuard=(Ie=class extends f{constructor(){super(...arguments);h(this,oe,"");h(this,le,null);h(this,he,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,oe)}set slot(t){c(this,oe,t)}get predicate(){return l(this,le)}set predicate(t){c(this,le,t)}get onMismatch(){return l(this,he)}set onMismatch(t){c(this,he,t)}createRenderRoot(){return this}get activeState(){const t=this.auth.state.status;if(t==="loading")return"loading";if(t!=="authenticated")return"unauthenticated";if(!this.predicate)return"authenticated";this.warnOnce(this.predicate);const e=this.auth.state.user;return S.matchesPredicate(e,this.predicate)?"authenticated":this.onMismatch==="hidden"?"hidden":"unauthenticated"}warnOnce(t){const e=JSON.stringify(t);if(this.warnedFor!==e){this.warnedFor=e;for(const s of S.validatePredicate(t))console.warn(`[singlebase] <singlebase-authui-guard> predicate: ${s}`)}}render(){const t=this.activeState;if(this.slot){const e=ws.includes(this.slot)&&this.slot===t;return this.toggleAttribute("hidden",!e),i.html`<slot></slot>`}this.toggleAttribute("hidden",!1);for(const e of Array.from(this.children)){const s=e.getAttribute("slot");e.toggleAttribute("hidden",s!==t)}return i.html`<slot></slot>`}},oe=new WeakMap,le=new WeakMap,he=new WeakMap,Ie);ve([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);ve([r.property({converter:{fromAttribute:o=>{if(!o)return null;try{return JSON.parse(o)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",o),null}},toAttribute:o=>o?JSON.stringify(o):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);ve([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=ve([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var Ke=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,Ss=(o,n,t)=>n in o?Ke(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,P=(o,n,t,e)=>{for(var s=e>1?void 0:e?ys(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&Ke(n,t,s),s},$s=(o,n,t)=>Ss(o,n+"",t);const Es="profile_photo";var ce,de,ue,pe,ge,Fe;exports.SinglebaseAuthDisplay=(Fe=class extends f{constructor(){super(...arguments);h(this,ce,"");h(this,de,"");h(this,ue,!1);h(this,pe,"");h(this,ge,!1)}get path(){return l(this,ce)}set path(t){c(this,ce,t)}get fallback(){return l(this,de)}set fallback(t){c(this,de,t)}get avatar(){return l(this,ue)}set avatar(t){c(this,ue,t)}get alt(){return l(this,pe)}set alt(t){c(this,pe,t)}get imageFailed(){return l(this,ge)}set imageFailed(t){c(this,ge,t)}willUpdate(t){super.willUpdate(t),(t.has("path")||t.has("avatar"))&&(this.imageFailed=!1)}get profile(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get textValue(){const t=this.profile;if(!t||!this.path)return"";const e=S.getPath(t,this.path);return e==null||e===""?"":Array.isArray(e)?e.filter(s=>s!=null).join(", "):typeof e=="object"?"":String(e)}get avatarSrc(){const t=this.profile;if(!t)return"";const e=S.getPath(t,this.path||Es);return typeof e=="string"?e:""}render(){if(this.auth.state.status==="loading")return i.nothing;if(this.avatar)return this.renderAvatar();const t=this.textValue;return t?i.html`<span part="text">${t}</span>`:this.fallback?i.html`<span part="text">${this.fallback}</span>`:i.nothing}renderAvatar(){const t=this.profile;if(!t)return i.nothing;const e=this.avatarSrc;return e&&!this.imageFailed?i.html`<img
|
|
908
|
-
part="avatar-image"
|
|
909
|
-
src=${e}
|
|
910
|
-
alt=${this.alt}
|
|
911
|
-
@error=${()=>this.imageFailed=!0}
|
|
912
|
-
/>`:i.html`<span
|
|
913
|
-
part="avatar-initials"
|
|
914
|
-
class="initials"
|
|
915
|
-
aria-hidden=${this.alt?"false":"true"}
|
|
916
|
-
>${Pe(t)}</span
|
|
917
|
-
>`}},ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,Fe);$s(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
|
|
918
|
-
/* Text sits in a sentence; an avatar is a box the host sizes. */
|
|
919
|
-
:host {
|
|
920
|
-
display: inline;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
:host([avatar]) {
|
|
924
|
-
display: inline-block;
|
|
925
|
-
width: 42px;
|
|
926
|
-
height: 42px;
|
|
927
|
-
vertical-align: middle;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
img,
|
|
931
|
-
.initials {
|
|
932
|
-
display: block;
|
|
933
|
-
width: 100%;
|
|
934
|
-
height: 100%;
|
|
935
|
-
border-radius: inherit;
|
|
936
|
-
box-sizing: border-box;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
img {
|
|
940
|
-
object-fit: cover;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
/* Matches the avatar in the account view. */
|
|
944
|
-
.initials {
|
|
945
|
-
display: flex;
|
|
946
|
-
align-items: center;
|
|
947
|
-
justify-content: center;
|
|
948
|
-
background: var(--sb-surface-alt, #fafafa);
|
|
949
|
-
border: 1px dashed var(--sb-border, #e4e6e9);
|
|
950
|
-
font-family: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
951
|
-
font-size: 0.8em;
|
|
952
|
-
color: var(--sb-muted-ink, #61666c);
|
|
953
|
-
user-select: none;
|
|
954
|
-
}
|
|
955
|
-
`]);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);P([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);P([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=P([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Re;exports.SettingsController=fe;exports.defaultMessages=we;exports.fullNameOf=Ce;exports.initialsOf=Pe;exports.isGuestScreen=ye;exports.isProtectedScreen=Ve;exports.isScreen=Se;exports.resolveMessages=je;
|
|
956
|
-
//# sourceMappingURL=authui-display-CMVHTNFz.cjs.map
|