Skip to content

Commit

Permalink
Merge pull request #17 from trusona/wip-credential-flag
Browse files Browse the repository at this point in the history
linting
  • Loading branch information
thitu authored Oct 28, 2023
2 parents ac7089b + a70df3c commit e1f9167
Show file tree
Hide file tree
Showing 17 changed files with 11,822 additions and 7,527 deletions.
2 changes: 2 additions & 0 deletions examples/simple-demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ async function showCredentialActivity (token) {
<div class="py-1">Browser: ${data['userAgent']}</div>
<div class="py-1">IP Address: ${data['ipAddress']}</div>
<div class="py-1">System OS: ${data['operatingSystem']}</div>
<div class="py-1">Synced: ${data['credentialFlags']?.BACKUP_STATE ?? 'n/a'}</div>
<div class="py-1">Sync Eligibility: ${data['credentialFlags']?.BACKUP_ELIGIBILITY ?? 'n/a'}</div>
<div class="py-1">When? ${moment(data['createdAt']).format('llll')}</div>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-demo/trusona-webauthn.standalone.js

Large diffs are not rendered by default.

19,287 changes: 11,789 additions & 7,498 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trusona/webauthn",
"version": "1.6.1",
"version": "1.6.2",
"description": "Trusona WebAuthn SDK",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down Expand Up @@ -51,10 +51,16 @@
"@npmcli/package-json": "^3.0.0",
"@types/jest": "^29.4.0",
"@types/node": "^18.14.2",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"babel-preset-env": "^1.7.0",
"browserify": "^17.0.0",
"cspell": "^6.27.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.52.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-tsdoc": "^0.2.17",
"esmify": "^2.1.1",
"jest": "^29.4.3",
Expand All @@ -65,8 +71,9 @@
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"ts-standard": "^12.0.2",
"typedoc": "^0.23.26",
"typescript": "^4.9",
"typescript": "<5.2.0",
"uglify-js": "^3.17.4"
},
"files": [
Expand Down
6 changes: 3 additions & 3 deletions src/lib/webauthn/core/authentication.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @jest-environment jsdom
*/
import { Authentication, WebAuthnAuthentication } from './authentication'
import { type Authentication, WebAuthnAuthentication } from './authentication'
import { Initializer } from './configuration'

describe('WebAuthnAuthentication', () => {
Expand All @@ -27,7 +27,7 @@ describe('WebAuthnAuthentication', () => {
Initializer.webauthnFeatures = { platformAuthenticator: true, conditionalMediation: true, webauthn: true }
authentication = new WebAuthnAuthentication()

// @ts-expect-error
// @ts-expect-error - not defined here .. ok
global.fetch = jest.fn(async () =>
await Promise.resolve({
status: 404,
Expand All @@ -47,7 +47,7 @@ describe('WebAuthnAuthentication', () => {
Initializer.webauthnFeatures = { platformAuthenticator: true, conditionalMediation: true, webauthn: true }
authentication = new WebAuthnAuthentication()

// @ts-expect-error
// @ts-expect-error - not defined here .. ok
global.fetch = jest.fn(async () =>
await Promise.resolve({
status: 202,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/webauthn/core/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { WebAuthnOptions } from './webauthn.options'
import { FailedAuthenticationError } from '../utils/errors'
import { Strings } from '../utils/strings'
import { Base } from './base'
import { PublicKeyCredentialRequestOptionsJSON, PublicKeyCredentialWithAssertionJSON } from '@github/webauthn-json/dist/types/basic/json'
import { KnownUsersService, initKnownUsersService } from '../known-users/known-users.service'
import { type PublicKeyCredentialRequestOptionsJSON, type PublicKeyCredentialWithAssertionJSON } from '@github/webauthn-json/dist/types/basic/json'
import { type KnownUsersService, initKnownUsersService } from '../known-users/known-users.service'

/**
* @description
Expand Down
1 change: 0 additions & 1 deletion src/lib/webauthn/core/configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { DefaultPreflightChecks } from '../preflight/preflight-checks'
import { Initializer } from './configuration'

Expand Down
3 changes: 1 addition & 2 deletions src/lib/webauthn/core/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import { DefaultPreflightChecks, Preflight } from '../preflight/preflight-checks'
import { DefaultPreflightChecks, type Preflight } from '../preflight/preflight-checks'

export interface Configuration {
tenantUrl: string
Expand Down
2 changes: 1 addition & 1 deletion src/lib/webauthn/core/enrollment.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @jest-environment jsdom
*/
import { Enrollment, WebAuthnEnrollment } from './enrollment'
import { type Enrollment, WebAuthnEnrollment } from './enrollment'
import { Initializer } from './configuration'

describe('WebAuthnEnrollment', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/webauthn/core/enrollment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as WebAuthn from '@github/webauthn-json/dist/types/basic/json'
import type * as WebAuthn from '@github/webauthn-json/dist/types/basic/json'
import * as errors from '../utils/errors'

import { KnownUsersService, initKnownUsersService } from '../known-users/known-users.service'
import { type KnownUsersService, initKnownUsersService } from '../known-users/known-users.service'
import { WebAuthnOptions } from './webauthn.options'
import { Initializer } from './configuration'
import { Strings } from '../utils/strings'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/webauthn/core/passkey-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @jest-environment jsdom
*/
import { Initializer } from './configuration'
import { DefaultPassKeyManagement, PassKeyManagement } from './passkey-management'
import { DefaultPassKeyManagement, type PassKeyManagement } from './passkey-management'

describe('PassKeyManagement', () => {
let passKeyManagement: PassKeyManagement
Expand Down
12 changes: 6 additions & 6 deletions src/lib/webauthn/core/passkey-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export interface PassKey {
}

export enum CredentialFlag {
BACKUP_STATE= 'BACKUP_STATE',
USER_PRESENT= 'USER_PRESENT',
USER_VERIFIED= 'USER_VERIFIED',
EXTENSION_DATA= 'EXTENSION_DATA',
BACKUP_ELIGIBILITY= 'BACKUP_ELIGIBILITY'
BACKUP_STATE = 'BACKUP_STATE',
USER_PRESENT = 'USER_PRESENT',
USER_VERIFIED = 'USER_VERIFIED',
EXTENSION_DATA = 'EXTENSION_DATA',
BACKUP_ELIGIBILITY = 'BACKUP_ELIGIBILITY'
}

export enum CredentialActivityType {
Expand All @@ -30,7 +30,7 @@ export interface PassKeyActivity {
ipAddress: string
operatingSystem: string
createdAt: Date
credentialFlags:Map<CredentialFlag, boolean>
credentialFlags: Map<CredentialFlag, boolean>
}

export interface PassKeyManagement {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/webauthn/core/webauthn.options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PublicKeyCredentialCreationOptionsJSON } from '@github/webauthn-json/dist/types/basic/json'
import { AssertionTransaction, CredentialTransaction } from './authentication'
import { type PublicKeyCredentialCreationOptionsJSON } from '@github/webauthn-json/dist/types/basic/json'
import { type AssertionTransaction, type CredentialTransaction } from './authentication'
import { Initializer } from './configuration'
import * as WebAuthn from '@github/webauthn-json'

Expand All @@ -21,7 +21,7 @@ export class WebAuthnOptions {
}

const credential: WebAuthn.PublicKeyCredentialWithAssertionJSON = await WebAuthn.get(params)
return requestOptions !== undefined ? { credential, transactionId } : await Promise.resolve(undefined)
return requestOptions !== undefined ? await Promise.resolve({ credential, transactionId }) : await Promise.resolve(undefined)
}

async createCredential (options: PublicKeyCredentialCreationOptionsJSON, abortSignal?: AbortSignal): Promise<WebAuthn.PublicKeyCredentialWithAttestationJSON> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/webauthn/known-users/known-users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @jest-environment jsdom
*/
import { DefaultKnownUsersService, KnownUsersService } from '../known-users/known-users.service'
import { DefaultKnownUsersService, type KnownUsersService } from '../known-users/known-users.service'

describe('KnownUsersService', () => {
const service: KnownUsersService = new DefaultKnownUsersService()
Expand Down
3 changes: 1 addition & 2 deletions src/lib/webauthn/preflight/preflight-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class DefaultPreflightChecks implements PreflightChecks {
}

private async isConditionalMediationAvailable (): Promise<boolean> {
// @ts-expect-error
return await window.PublicKeyCredential?.isConditionalMediationAvailable?.() // eslint-disable-line @typescript-eslint/return-await
return await window.PublicKeyCredential?.isConditionalMediationAvailable?.()
}

private async isUserVerifyingPlatformAuthenticatorAvailable (): Promise<boolean> {
Expand Down
1 change: 0 additions & 1 deletion src/lib/webauthn/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export class UnsupportedBrowserError extends Error {
constructor () {
super('This browser is not supported')
Expand Down
1 change: 0 additions & 1 deletion src/lib/webauthn/utils/strings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export const Strings = {

blank (value: string): boolean {
Expand Down

0 comments on commit e1f9167

Please sign in to comment.