Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint it! #39

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 59 additions & 62 deletions src/components/fido-passkey-details-card/fido-passkey-details-card.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {LitElement, html, css, TemplateResult} from 'lit'
import {customElement, property} from 'lit/decorators.js'
import {repeat} from 'lit/directives/repeat.js'
import {sharedStyles} from '../../shared/style'
import {DateTime} from 'luxon';
import { LitElement, html, css, TemplateResult } from 'lit'
import { customElement, property } from 'lit/decorators.js'
import { repeat } from 'lit/directives/repeat.js'
import { sharedStyles } from '../../shared/style'
import { DateTime } from 'luxon'

const componentStyle = css`

Expand Down Expand Up @@ -85,26 +85,24 @@ const componentStyle = css`
`

export interface PasskeyActivity {
lastUsedAt: string
operatingSystem: string
lastUsedAt: string
operatingSystem: string
}

export interface PasskeyDetails {
createdAt: string
createdOperatingSystem: string
passkeyActivity: Array<PasskeyActivity>
createdAt: string
createdOperatingSystem: string
passkeyActivity: PasskeyActivity[]
}

@customElement('fido-passkey-details-card')
class FidoPasskeyDetailsCard extends LitElement {
@property({ type: Object }) passkeyDetails?: PasskeyDetails

@property({type: Object}) passkeyDetails?: PasskeyDetails
static styles = [sharedStyles, componentStyle]

static styles = [sharedStyles, componentStyle]

render(): TemplateResult {
// console.log(this.passkeyDetails)
return html`
render (): TemplateResult {
return html`
<div class="auth-card">
<div class="auth-card-header">
<svg class="auth-img" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down Expand Up @@ -133,67 +131,66 @@ class FidoPasskeyDetailsCard extends LitElement {
</div>
</div>
`
}
}

private getCreatedAtText(): string {
const createdAt = this.passkeyDetails?.createdAt
const os = this.passkeyDetails?.createdOperatingSystem
const formattedDate = this.getFormattedDate(createdAt ?? "")
if (formattedDate) {
return `Saved with ${os ?? "--"} on ${formattedDate}`
} else {
return ""
}
private getCreatedAtText (): string {
const createdAt = this.passkeyDetails?.createdAt
const os = this.passkeyDetails?.createdOperatingSystem
const formattedDate = this.getFormattedDate(createdAt ?? '')
if (formattedDate) {
return `Saved with ${os ?? '--'} on ${formattedDate}`
} else {
return ''
}
}

private getLastUsedAtText(lastUsedAt?: string, lastUsedOs?: String): string {
const formattedDate = this.getFormattedDate(lastUsedAt ?? "")
return `${lastUsedOs ?? ""}, ${formattedDate}`
}
private getLastUsedAtText (lastUsedAt?: string, lastUsedOs?: String): string {
const formattedDate = this.getFormattedDate(lastUsedAt ?? '')
return `${lastUsedOs ?? ''}, ${formattedDate}`
}

private getFormattedDate(date: string) {
const parsedDate = DateTime.fromISO(date);
if (parsedDate.isValid) {
return parsedDate.toFormat("MMM d, yyyy, h:mm a ZZZZ")
} else {
return ""
}
private getFormattedDate (date: string) {
const parsedDate = DateTime.fromISO(date)
if (parsedDate.isValid) {
return parsedDate.toFormat('MMM d, yyyy, h:mm a ZZZZ')
} else {
return ''
}
}

private getLastUsedActivity(): TemplateResult {
const activityList = this.passkeyDetails?.passkeyActivity
if (Array.isArray(activityList) && activityList.length > 0) {
return html`
private getLastUsedActivity (): TemplateResult {
const activityList = this.passkeyDetails?.passkeyActivity
if (Array.isArray(activityList) && activityList.length > 0) {
return html`
${repeat(this.passkeyDetails?.passkeyActivity ?? [], (activity: PasskeyActivity) => html`
${this.getActivityRow(activity)}
`)}`
} else {
return html`
} else {
return html`
${this.getActivityRow({
lastUsedAt: this.passkeyDetails?.createdAt ?? "",
operatingSystem: this.passkeyDetails?.createdOperatingSystem ?? ""
lastUsedAt: this.passkeyDetails?.createdAt ?? '',
operatingSystem: this.passkeyDetails?.createdOperatingSystem ?? ''
})}
`
}
}
}

private isMobile (operatingSystem?: string) {
return operatingSystem?.toLowerCase().includes('android') || operatingSystem?.toLowerCase().includes('ios')
}

private isMobile(operatingSystem?: string) {
return operatingSystem?.toLowerCase().includes('android') || operatingSystem?.toLowerCase().includes('ios')
}

private getActivityRow(activity: PasskeyActivity): TemplateResult {
return html`
private getActivityRow (activity: PasskeyActivity): TemplateResult {
return html`
<div class="auth-card-row">
${this.getIcon(this.isMobile(activity.operatingSystem) ?? false)}
<p class="auth-card-h3">${this.getLastUsedAtText(activity.lastUsedAt, activity.operatingSystem)}</p>
</div>
`
}
}

private getIcon(isMobile: boolean): TemplateResult {
if (isMobile) {
return html`
private getIcon (isMobile: boolean): TemplateResult {
if (isMobile) {
return html`
<svg class="passkey-type-img" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.6114 11.6851H4.38916" stroke="#444444" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M10.5003 1.7959H5.50027C4.88662 1.7959 4.38916 2.29336 4.38916 2.90701V13.4626C4.38916 14.0762 4.88662 14.5737 5.50027 14.5737H10.5003C11.1139 14.5737 11.6114 14.0762 11.6114 13.4626V2.90701C11.6114 2.29336 11.1139 1.7959 10.5003 1.7959Z"
Expand All @@ -202,8 +199,8 @@ class FidoPasskeyDetailsCard extends LitElement {
fill="#444444"/>
</svg>
`
} else {
return html`
} else {
return html`
<svg class="passkey-type-img" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_5534_164)">
<path d="M14.4995 9.68506V3.18506C14.4995 2.35173 13.8262 1.68506 12.9995 1.68506H2.99951C2.16618 1.68506 1.49951 2.35173 1.49951 3.18506V9.68506C1.49951 9.95839 1.71951 10.1851 1.99951 10.1851H13.9995C14.2728 10.1851 14.4995 9.95839 14.4995 9.68506ZM13.4995 9.68506L13.9995 9.18506H1.99951L2.49951 9.68506V3.18506C2.49951 2.90506 2.71951 2.68506 2.99951 2.68506H12.9995C13.2728 2.68506 13.4995 2.90506 13.4995 3.18506V9.68506Z"
Expand All @@ -220,12 +217,12 @@ class FidoPasskeyDetailsCard extends LitElement {
</defs>
</svg>
`
}
}
}
}

declare global {
interface HTMLElementTagNameMap {
'fido-passkey-details-card': FidoPasskeyDetailsCard
}
interface HTMLElementTagNameMap {
'fido-passkey-details-card': FidoPasskeyDetailsCard
}
}
32 changes: 16 additions & 16 deletions src/fido/fido-passkey-details/fido-passkey-details.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {LitElement, html, css, TemplateResult} from 'lit'
import {repeat} from 'lit/directives/repeat.js'
import {customElement, property} from 'lit/decorators.js'
import {sharedStyles} from '../../shared/style'
import {PasskeyDetails} from "../../components/fido-passkey-details-card/fido-passkey-details-card";
import { LitElement, html, css, TemplateResult } from 'lit'
import { repeat } from 'lit/directives/repeat.js'
import { customElement, property } from 'lit/decorators.js'
import { sharedStyles } from '../../shared/style'
import { PasskeyDetails } from '../../components/fido-passkey-details-card/fido-passkey-details-card'

const componentStyle = css`

Expand Down Expand Up @@ -57,12 +57,12 @@ const componentStyle = css`

@customElement('fido-passkey-details')
class FidoPasskeyDetails extends LitElement {
@property({type: Array}) passkeyDetails: PasskeyDetails[] = new Array<PasskeyDetails>()
@property({ type: Array }) passkeyDetails: PasskeyDetails[] = new Array<PasskeyDetails>()

static styles = [sharedStyles, componentStyle]
static styles = [sharedStyles, componentStyle]

render(): TemplateResult {
return html`
render (): TemplateResult {
return html`
<div class="auth-container">
<p class="auth-h1">Passkeys</p>
${this.getPasskeys()}
Expand All @@ -85,20 +85,20 @@ class FidoPasskeyDetails extends LitElement {
</div>
</div>
`
}
}

private getPasskeys(): TemplateResult {
return html`
private getPasskeys (): TemplateResult {
return html`
${repeat(this.passkeyDetails, (details: PasskeyDetails) => html`
<fido-passkey-details-card passkeyDetails="${JSON.stringify(details)}">
</fido-passkey-details-card>
`)}
`
}
}
}

declare global {
interface HTMLElementTagNameMap {
'fido-passkey-details': FidoPasskeyDetails
}
interface HTMLElementTagNameMap {
'fido-passkey-details': FidoPasskeyDetails
}
}
50 changes: 25 additions & 25 deletions src/touchpoints/username-password/username-password.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, css, LitElement } from 'lit'
import { html, css, LitElement, TemplateResult } from 'lit'
import { property, customElement, query } from 'lit/decorators.js'
import { sharedStyles } from '../../shared/style'
import { LoginStep } from '../../utils/login.model'
Expand Down Expand Up @@ -49,48 +49,48 @@ class UsernamePasswordTouchpoint extends LitElement {
return this.login.userIdentifier ?? ''
}

onPasswordChange (event: Event) {
onPasswordChange (event: Event): void {
this.waitingForInput = (event.target as HTMLInputElement).value === ''
this.requestUpdate()
}

resetButtonClicked (event: Event) {
resetButtonClicked (event: Event): boolean {
event.preventDefault()
if (this.startOver) {
if (this.startOver !== undefined) {
this.startOver(event)
}
return false
}

togglePasswordVisibility (): void {
this.showPassword = !this.showPassword
if (this.passwordInput) {
if (this.passwordInput !== undefined) {
this.passwordInput.type = this.showPassword ? 'text' : 'password'
}
}

prePerformLogin (): any {
prePerformLogin (): void {
this.performLogin({
username: this.login.userIdentifier,
password: this.passwordInput.value
})
}

preCheckSignInAnotherWay () {
preCheckSignInAnotherWay (): void {
this.signInAnotherWay()
}

inputPlaceholder () {
if (this.passwordSignIn?.hideInputHint) {
inputPlaceholder (): string {
if (this.passwordSignIn?.hideInputHint !== undefined) {
return ''
} else {
return this.passwordSignIn?.inputHint || 'Enter Password'
return this.passwordSignIn?.inputHint ?? 'Enter Password'
}
}

render () {
render (): TemplateResult {
return html`
${this.currentStep(LoginStep.ProvideUsername)
${this.currentStep(LoginStep.ProvideUsername) === true
? html`
<start-touchpoint
?started=${this.started}
Expand All @@ -114,9 +114,9 @@ class UsernamePasswordTouchpoint extends LitElement {
<flex-container .globalStyles=${this.globalStyles}>
<header-1 ?hidden=${this.passwordSignIn?.hideHeadline}
style=${this.globalStyles?.heading1Style}>
${this.passwordSignIn?.headline || 'Sign in'}
${this.passwordSignIn?.headline ?? 'Sign in'}
</header-1>
${this.isError('response')
${this.isError('response') === true
? html`
<div class="error-msg">
<div>
Expand All @@ -139,38 +139,38 @@ class UsernamePasswordTouchpoint extends LitElement {
: ''}

<div style="position: relative;">
${!this.currentStep(LoginStep.ProvideUsername)
${this.currentStep(LoginStep.ProvideUsername) === false
? html`
<div class="auth-ui-input-wrapper">
<auth-reset .callback="${this.resetButtonClicked}">${this.getUserIdentifier()}
</auth-reset>
</div>
`
: ''}
<p ?hidden=${!this.isError(this.getUserIdentifier())} class="mt-2 text-sm text-red-600">
<p ?hidden=${this.isError(this.getUserIdentifier()) === false} class="mt-2 text-sm text-red-600">
<span class="font-medium">Username or password</span> is required
</p>
</div>

<div ?hidden="${!this.currentStep(LoginStep.ProvidePassword)}" style="position: relative;">
<div ?hidden="${this.currentStep(LoginStep.ProvidePassword) === false}" style="position: relative;">
<div class="auth-ui-input-wrapper">
<label ?hidden="${!this.passwordSignIn?.hideInputLabel ?? false}"
<label ?hidden="${this.passwordSignIn?.hideInputLabel === false ?? false}"
class="auth-ui-label"
style="${this.globalStyles?.paragraphStyle ?? ''}"
for="password">
${this.passwordSignIn?.inputLabel || 'Password'}
${this.passwordSignIn?.inputLabel ?? 'Password'}
</label>
<div class="password-input-container">
<input class="auth-ui-input"
?disabled=${!this.currentStep(LoginStep.ProvidePassword)}
?disabled=${this.currentStep(LoginStep.ProvidePassword) === false}
@input=${(ev: Event) => { this.onPasswordChange(ev) }}
placeholder=${this.inputPlaceholder()}
id="password"
name="password"
type="${this.showPassword ? 'text' : 'password'}"
required>

${!this.passwordSignIn?.hidePasswordToggle && !this.showPassword
${this.passwordSignIn?.hidePasswordToggle === false && this.showPassword === false
? html`
<button title="Show password"
class="password-toggle-icon"
Expand All @@ -185,7 +185,7 @@ class UsernamePasswordTouchpoint extends LitElement {
`
: ''}

${!this.passwordSignIn?.hidePasswordToggle && this.showPassword
${this.passwordSignIn?.hidePasswordToggle === false && this.showPassword !== undefined
? html`
<button title="Hide password"
class="password-toggle-icon"
Expand All @@ -211,13 +211,13 @@ class UsernamePasswordTouchpoint extends LitElement {
?isProcessing=${this.started}
?isWaitingForInput=${this.waitingForInput}
inlineStyle="${this.globalStyles?.buttonStyle}"
btnId="loginSubmitBtn">${this.passwordSignIn?.buttonText || 'Continue'}
btnId="loginSubmitBtn">${this.passwordSignIn?.buttonText ?? 'Continue'}
</auth-button>

${!this.passwordSignIn?.hideMessage
${this.passwordSignIn?.hideMessage === false
? html`
<text-block inlineStyle="${this.globalStyles?.paragraphStyle}">
${this.passwordSignIn?.message || 'By continuing, you agree to our privacy policy and terms of use.'}
${this.passwordSignIn?.message ?? 'By continuing, you agree to our privacy policy and terms of use.'}
</text-block>
`
: ''}
Expand Down
Loading