Skip to content

Commit

Permalink
fix all types
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Sep 25, 2024
1 parent a77a7ca commit bbf367c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
11 changes: 4 additions & 7 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,10 @@ export default defineNuxtModule<ModuleOptions>({
}

// WebAuthn settings
if (options.webAuthn) {
// @ts-expect-error typing error
runtimeConfig.webauthn = defu(runtimeConfig.webauthn, {
register: {},
authenticate: {},
})
}
runtimeConfig.webauthn = defu(runtimeConfig.webauthn, {
register: {},
authenticate: {},
})

// OAuth settings
runtimeConfig.oauth = defu(runtimeConfig.oauth, {})
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/app/composables/webauthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import type { VerifiedAuthenticationResponse, VerifiedRegistrationResponse } from '@simplewebauthn/server'
import type { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'
import { ref, onMounted } from '#imports'
import type { WebauthnComposable } from '#auth-utils'
import type { WebAuthnComposable } from '#auth-utils'

interface RegistrationInitResponse {
creationOptions: PublicKeyCredentialCreationOptionsJSON
Expand All @@ -31,7 +31,7 @@ export function useWebauthn(options: {
* @default '/api/webauthn/authenticate'
*/
authenticateEndpoint?: string
} = {}): WebauthnComposable {
} = {}): WebAuthnComposable {
const { registerEndpoint = '/api/webauthn/register', authenticateEndpoint = '/api/webauthn/authenticate' } = options
async function register(userName: string, displayName?: string) {
const { creationOptions, attemptId } = await $fetch<RegistrationInitResponse>(registerEndpoint, {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/webauthn/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getRandomValues } from 'uncrypto'
import { base64URLStringToBuffer, bufferToBase64URLString } from '@simplewebauthn/browser'
import { storeChallengeAsSession, getChallengeFromSession } from './utils'
import { useRuntimeConfig } from '#imports'
import type { CredentialAuthenticationEventHandlerOptions } from '#auth-utils'
import type { WebAuthnAuthenticateEventHandlerOptions } from '#auth-utils'

type AuthenticationBody = {
verify: false
Expand All @@ -26,7 +26,7 @@ export function defineWebAuthnAuthenticateEventHandler({
getOptions,
onSuccess,
onError,
}: CredentialAuthenticationEventHandlerOptions) {
}: WebAuthnAuthenticateEventHandlerOptions) {
return eventHandler(async (event) => {
const url = getRequestURL(event)
const body = await readBody<AuthenticationBody>(event)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/lib/webauthn/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { bufferToBase64URLString } from '@simplewebauthn/browser'
import { getRandomValues } from 'uncrypto'
import { storeChallengeAsSession, getChallengeFromSession } from './utils'
import { useRuntimeConfig } from '#imports'
import type { CredentialRegistrationEventHandlerOptions } from '#auth-utils'
import type { WebAuthnRegisterEventHandlerOptions } from '#auth-utils'

type RegistrationBody = {
userName: string
Expand All @@ -27,7 +27,7 @@ export function defineWebAuthnRegisterEventHandler({
getOptions,
onSuccess,
onError,
}: CredentialRegistrationEventHandlerOptions) {
}: WebAuthnRegisterEventHandlerOptions) {
return eventHandler(async (event) => {
const url = getRequestURL(event)
const body = await readBody<RegistrationBody>(event)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type { User, UserSession, UserSessionRequired, UserSessionComposable, SecureSessionData } from './session'
export type { OAuthConfig, OAuthProvider, OnError } from './oauth-config'
export type {
AuthenticatorDevice,
WebAuthnAuthenticatorDevice,
WebAuthnRegisterEventHandlerOptions,
WebAuthnAuthenticateEventHandlerOptions,
WebAuthnComposable,
Expand Down

0 comments on commit bbf367c

Please sign in to comment.