@auth/core
Advanced tools
Comparing version 0.26.1 to 0.26.2
import type { Cookie } from "../../utils/cookie.js"; | ||
import type { InternalOptions, RequestInternal, ResponseInternal } from "../../../types"; | ||
import type { InternalOptions, RequestInternal, ResponseInternal } from "../../../types.js"; | ||
export declare function signIn(request: RequestInternal, cookies: Cookie[], options: InternalOptions): Promise<ResponseInternal>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -66,3 +66,3 @@ import { renderToString } from "preact-render-to-string"; | ||
const { simpleWebAuthnBrowserVersion } = webauthnProvider; | ||
simpleWebAuthnBrowserScript = `<script src="https://unpkg.com/browse/@simplewebauthn/browser@${simpleWebAuthnBrowserVersion}/dist/bundle/index.umd.min.js" crossorigin="anonymous"></script>`; | ||
simpleWebAuthnBrowserScript = `<script src="https://unpkg.com/@simplewebauthn/browser@${simpleWebAuthnBrowserVersion}/dist/bundle/index.umd.min.js" crossorigin="anonymous"></script>`; | ||
} | ||
@@ -69,0 +69,0 @@ return send({ |
@@ -1,2 +0,2 @@ | ||
import type { AuthAction, AuthConfig } from "../../types"; | ||
import type { AuthAction, AuthConfig } from "../../types.js"; | ||
/** Set default env variables on the config object */ | ||
@@ -3,0 +3,0 @@ export declare function setEnvDefaults(envObject: any, config: AuthConfig): void; |
@@ -1,3 +0,3 @@ | ||
import type { InternalOptions, User } from "../../types"; | ||
import type { SessionStore } from "./cookie"; | ||
import type { InternalOptions, User } from "../../types.js"; | ||
import type { SessionStore } from "./cookie.js"; | ||
/** | ||
@@ -4,0 +4,0 @@ * Returns the currently logged in user, if any. |
@@ -1,7 +0,7 @@ | ||
import type { WebAuthnProviderType } from "../../providers/webauthn"; | ||
import type { Account, Authenticator, Awaited, InternalOptions, RequestInternal, ResponseInternal, User } from "../../types"; | ||
import type { Cookie } from "./cookie"; | ||
import type { WebAuthnProviderType } from "../../providers/webauthn.js"; | ||
import type { Account, Authenticator, Awaited, InternalOptions, RequestInternal, ResponseInternal, User } from "../../types.js"; | ||
import type { Cookie } from "./cookie.js"; | ||
import type { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from "@simplewebauthn/server/script/deps"; | ||
import type { Adapter, AdapterAccount } from "../../adapters"; | ||
import type { GetUserInfo } from "../../providers/webauthn"; | ||
import type { Adapter, AdapterAccount } from "../../adapters.js"; | ||
import type { GetUserInfo } from "../../providers/webauthn.js"; | ||
export type WebAuthnRegister = "register"; | ||
@@ -8,0 +8,0 @@ export type WebAuthnAuthenticate = "authenticate"; |
@@ -1,4 +0,4 @@ | ||
import { AdapterError, AuthError, InvalidProvider, MissingAdapter, WebAuthnVerificationError } from "../../errors"; | ||
import { webauthnChallenge } from "../actions/callback/oauth/checks"; | ||
import { randomString } from "./web"; | ||
import { AdapterError, AuthError, InvalidProvider, MissingAdapter, WebAuthnVerificationError, } from "../../errors.js"; | ||
import { webauthnChallenge } from "../actions/callback/oauth/checks.js"; | ||
import { randomString } from "./web.js"; | ||
/** | ||
@@ -114,4 +114,9 @@ * Infers the WebAuthn options based on the provided parameters. | ||
// Get WebAuthn response from request body | ||
const data = request.body && typeof request.body.data === "string" ? JSON.parse(request.body.data) : undefined; | ||
if (!data || typeof data !== "object" || !("id" in data) || typeof data.id !== "string") { | ||
const data = request.body && typeof request.body.data === "string" | ||
? JSON.parse(request.body.data) | ||
: undefined; | ||
if (!data || | ||
typeof data !== "object" || | ||
!("id" in data) || | ||
typeof data.id !== "string") { | ||
throw new AuthError("Invalid WebAuthn Authentication response."); | ||
@@ -124,3 +129,5 @@ } | ||
if (!authenticator) { | ||
throw new AuthError(`WebAuthn authenticator not found in database: ${JSON.stringify({ credentialID })}`); | ||
throw new AuthError(`WebAuthn authenticator not found in database: ${JSON.stringify({ | ||
credentialID, | ||
})}`); | ||
} | ||
@@ -165,7 +172,14 @@ // Get challenge from request cookies | ||
if (!account) { | ||
throw new AuthError(`WebAuthn account not found in database: ${JSON.stringify({ credentialID, providerAccountId: authenticator.providerAccountId })}`); | ||
throw new AuthError(`WebAuthn account not found in database: ${JSON.stringify({ | ||
credentialID, | ||
providerAccountId: authenticator.providerAccountId, | ||
})}`); | ||
} | ||
const user = await adapter.getUser(account.userId); | ||
if (!user) { | ||
throw new AuthError(`WebAuthn user not found in database: ${JSON.stringify({ credentialID, providerAccountId: authenticator.providerAccountId, userID: account.userId })}`); | ||
throw new AuthError(`WebAuthn user not found in database: ${JSON.stringify({ | ||
credentialID, | ||
providerAccountId: authenticator.providerAccountId, | ||
userID: account.userId, | ||
})}`); | ||
} | ||
@@ -180,4 +194,9 @@ return { | ||
// Get WebAuthn response from request body | ||
const data = request.body && typeof request.body.data === "string" ? JSON.parse(request.body.data) : undefined; | ||
if (!data || typeof data !== "object" || !("id" in data) || typeof data.id !== "string") { | ||
const data = request.body && typeof request.body.data === "string" | ||
? JSON.parse(request.body.data) | ||
: undefined; | ||
if (!data || | ||
typeof data !== "object" || | ||
!("id" in data) || | ||
typeof data.id !== "string") { | ||
throw new AuthError("Invalid WebAuthn Registration response."); | ||
@@ -223,3 +242,4 @@ } | ||
credentialDeviceType: verification.registrationInfo.credentialDeviceType, | ||
transports: transportsToString(data.response.transports) | ||
transports: transportsToString(data.response | ||
.transports), | ||
}; | ||
@@ -244,5 +264,5 @@ // Return created stuff | ||
// Get the user's authenticators. | ||
const authenticators = user && user["id"] ? | ||
await adapter.listAuthenticatorsByUserId(user.id) : | ||
null; | ||
const authenticators = user && user["id"] | ||
? await adapter.listAuthenticatorsByUserId(user.id) | ||
: null; | ||
const relayingParty = provider.getRelayingParty(options, request); | ||
@@ -271,3 +291,5 @@ // Return the authentication options. | ||
// Get the user's authenticators. | ||
const authenticators = user["id"] ? await adapter.listAuthenticatorsByUserId(user.id) : null; | ||
const authenticators = user["id"] | ||
? await adapter.listAuthenticatorsByUserId(user.id) | ||
: null; | ||
// Generate a random user ID for the credential. | ||
@@ -325,3 +347,5 @@ // We can do this because we don't use this user ID to link the | ||
export function stringToTransports(tstring) { | ||
return tstring ? tstring.split(",") : undefined; | ||
return tstring | ||
? tstring.split(",") | ||
: undefined; | ||
} |
{ | ||
"name": "@auth/core", | ||
"version": "0.26.1", | ||
"version": "0.26.2", | ||
"description": "Authentication for the Web.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth"; | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth.js"; | ||
/** [Get a user](https://api.mattermost.com/#tag/users/operation/GetUser) */ | ||
@@ -14,0 +14,0 @@ export interface MattermostProfile { |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import type { OAuthConfig, OAuthUserConfig } from "."; | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth.js"; | ||
export interface Person extends Record<string, any> { | ||
@@ -14,0 +14,0 @@ email: string; |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import { WebAuthnConfig } from "./webauthn"; | ||
import { WebAuthnConfig } from "./webauthn.js"; | ||
/** | ||
@@ -14,0 +14,0 @@ * Add Passkey login to your page. |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import WebAuthn, { DEFAULT_WEBAUTHN_TIMEOUT } from "./webauthn"; | ||
import WebAuthn, { DEFAULT_WEBAUTHN_TIMEOUT, } from "./webauthn.js"; | ||
/** | ||
@@ -14,0 +14,0 @@ * Add Passkey login to your page. |
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server"; | ||
import type { CommonProviderOptions, CredentialInput } from "."; | ||
import type { CommonProviderOptions, CredentialInput } from "./index.js"; | ||
import type { GenerateRegistrationOptionsOpts, GenerateAuthenticationOptionsOpts, VerifyAuthenticationResponseOpts, VerifyRegistrationResponseOpts } from "@simplewebauthn/server"; | ||
@@ -4,0 +4,0 @@ import type { InternalOptions, RequestInternal, SemverString, User } from "../types.js"; |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import { OAuthConfig, OAuthUserConfig } from "."; | ||
import { OAuthConfig, OAuthUserConfig } from "./oauth.js"; | ||
/** | ||
@@ -14,0 +14,0 @@ * - {@link https://yandex.com/dev/id/doc/en/user-information | Getting information about the user} |
@@ -9,3 +9,3 @@ import { getAuthorizationUrl } from "./authorization-url.js" | ||
ResponseInternal, | ||
} from "../../../types" | ||
} from "../../../types.js" | ||
@@ -12,0 +12,0 @@ export async function signIn( |
@@ -107,3 +107,3 @@ import { renderToString } from "preact-render-to-string" | ||
const { simpleWebAuthnBrowserVersion } = webauthnProvider | ||
simpleWebAuthnBrowserScript = `<script src="https://unpkg.com/browse/@simplewebauthn/browser@${simpleWebAuthnBrowserVersion}/dist/bundle/index.umd.min.js" crossorigin="anonymous"></script>` | ||
simpleWebAuthnBrowserScript = `<script src="https://unpkg.com/@simplewebauthn/browser@${simpleWebAuthnBrowserVersion}/dist/bundle/index.umd.min.js" crossorigin="anonymous"></script>` | ||
} | ||
@@ -110,0 +110,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { AuthAction, AuthConfig } from "../../types" | ||
import type { AuthAction, AuthConfig } from "../../types.js" | ||
@@ -3,0 +3,0 @@ /** Set default env variables on the config object */ |
@@ -1,3 +0,3 @@ | ||
import type { InternalOptions, User } from "../../types"; | ||
import type { SessionStore } from "./cookie"; | ||
import type { InternalOptions, User } from "../../types.js" | ||
import type { SessionStore } from "./cookie.js" | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,7 +0,21 @@ | ||
import type { WebAuthnProviderType } from "../../providers/webauthn"; | ||
import type { Account, Authenticator, Awaited, InternalOptions, RequestInternal, ResponseInternal, User } from "../../types"; | ||
import type { Cookie } from "./cookie"; | ||
import { AdapterError, AuthError, InvalidProvider, MissingAdapter, WebAuthnVerificationError } from "../../errors"; | ||
import { webauthnChallenge } from "../actions/callback/oauth/checks"; | ||
import type { WebAuthnProviderType } from "../../providers/webauthn.js" | ||
import type { | ||
Account, | ||
Authenticator, | ||
Awaited, | ||
InternalOptions, | ||
RequestInternal, | ||
ResponseInternal, | ||
User, | ||
} from "../../types.js" | ||
import type { Cookie } from "./cookie.js" | ||
import { | ||
AdapterError, | ||
AuthError, | ||
InvalidProvider, | ||
MissingAdapter, | ||
WebAuthnVerificationError, | ||
} from "../../errors.js" | ||
import { webauthnChallenge } from "../actions/callback/oauth/checks.js" | ||
import type { | ||
AuthenticationResponseJSON, | ||
@@ -12,6 +26,13 @@ PublicKeyCredentialCreationOptionsJSON, | ||
} from "@simplewebauthn/server/script/deps" | ||
import type { Adapter, AdapterAccount, AdapterAuthenticator } from "../../adapters"; | ||
import type { GetUserInfo } from "../../providers/webauthn"; | ||
import { randomString } from "./web"; | ||
import type { VerifiedAuthenticationResponse, VerifiedRegistrationResponse } from "@simplewebauthn/server"; | ||
import type { | ||
Adapter, | ||
AdapterAccount, | ||
AdapterAuthenticator, | ||
} from "../../adapters.js" | ||
import type { GetUserInfo } from "../../providers/webauthn.js" | ||
import { randomString } from "./web.js" | ||
import type { | ||
VerifiedAuthenticationResponse, | ||
VerifiedRegistrationResponse, | ||
} from "@simplewebauthn/server" | ||
@@ -22,10 +43,14 @@ export type WebAuthnRegister = "register" | ||
type InternalOptionsWebAuthn = InternalOptions<WebAuthnProviderType> & { adapter: Required<Adapter> } | ||
export type WebAuthnOptionsResponseBody = { | ||
action: WebAuthnAuthenticate, | ||
options: PublicKeyCredentialRequestOptionsJSON | ||
} | { | ||
action: WebAuthnRegister, | ||
options: PublicKeyCredentialCreationOptionsJSON | ||
type InternalOptionsWebAuthn = InternalOptions<WebAuthnProviderType> & { | ||
adapter: Required<Adapter> | ||
} | ||
export type WebAuthnOptionsResponseBody = | ||
| { | ||
action: WebAuthnAuthenticate | ||
options: PublicKeyCredentialRequestOptionsJSON | ||
} | ||
| { | ||
action: WebAuthnRegister | ||
options: PublicKeyCredentialCreationOptionsJSON | ||
} | ||
type WebAuthnOptionsResponse = ResponseInternal & { | ||
@@ -50,7 +75,7 @@ body: WebAuthnOptionsResponseBody | ||
* Infers the WebAuthn options based on the provided parameters. | ||
* | ||
* | ||
* @param action - The WebAuthn action to perform (optional). | ||
* @param loggedInUser - The logged-in user (optional). | ||
* @param userInfoResponse - The response containing user information (optional). | ||
* | ||
* | ||
* @returns The WebAuthn action to perform, or null if no inference could be made. | ||
@@ -78,4 +103,3 @@ */ | ||
*/ | ||
if (user && loggedIn === exists) | ||
return "register" | ||
if (user && loggedIn === exists) return "register" | ||
break | ||
@@ -112,3 +136,3 @@ } | ||
* Retrieves the registration response for WebAuthn options request. | ||
* | ||
* | ||
* @param options - The internal options for WebAuthn. | ||
@@ -129,3 +153,7 @@ * @param request - The request object. | ||
// Get signed cookie | ||
const { cookie } = await webauthnChallenge.create(options, regOptions.challenge, user) | ||
const { cookie } = await webauthnChallenge.create( | ||
options, | ||
regOptions.challenge, | ||
user | ||
) | ||
@@ -147,3 +175,3 @@ return { | ||
* Retrieves the authentication response for WebAuthn options request. | ||
* | ||
* | ||
* @param options - The internal options for WebAuthn. | ||
@@ -164,3 +192,6 @@ * @param request - The request object. | ||
// Get signed cookie | ||
const { cookie } = await webauthnChallenge.create(options, authOptions.challenge) | ||
const { cookie } = await webauthnChallenge.create( | ||
options, | ||
authOptions.challenge | ||
) | ||
@@ -184,8 +215,16 @@ return { | ||
resCookies: Cookie[] | ||
): Promise<{ account: AdapterAccount, user: User }> { | ||
): Promise<{ account: AdapterAccount; user: User }> { | ||
const { adapter, provider } = options | ||
// Get WebAuthn response from request body | ||
const data = request.body && typeof request.body.data === "string" ? JSON.parse(request.body.data) as unknown : undefined | ||
if (!data || typeof data !== "object" || !("id" in data) || typeof data.id !== "string") { | ||
const data = | ||
request.body && typeof request.body.data === "string" | ||
? (JSON.parse(request.body.data) as unknown) | ||
: undefined | ||
if ( | ||
!data || | ||
typeof data !== "object" || | ||
!("id" in data) || | ||
typeof data.id !== "string" | ||
) { | ||
throw new AuthError("Invalid WebAuthn Authentication response.") | ||
@@ -200,7 +239,15 @@ } | ||
if (!authenticator) { | ||
throw new AuthError(`WebAuthn authenticator not found in database: ${JSON.stringify({ credentialID })}`) | ||
throw new AuthError( | ||
`WebAuthn authenticator not found in database: ${JSON.stringify({ | ||
credentialID, | ||
})}` | ||
) | ||
} | ||
// Get challenge from request cookies | ||
const { challenge: expectedChallenge } = await webauthnChallenge.use(options, request.cookies, resCookies) | ||
const { challenge: expectedChallenge } = await webauthnChallenge.use( | ||
options, | ||
request.cookies, | ||
resCookies | ||
) | ||
@@ -227,3 +274,5 @@ // Verify the response | ||
if (!verified) { | ||
throw new WebAuthnVerificationError("WebAuthn authentication response could not be verified.") | ||
throw new WebAuthnVerificationError( | ||
"WebAuthn authentication response could not be verified." | ||
) | ||
} | ||
@@ -234,16 +283,31 @@ | ||
const { newCounter } = authenticationInfo | ||
await adapter.updateAuthenticatorCounter(authenticator.credentialID, newCounter) | ||
await adapter.updateAuthenticatorCounter( | ||
authenticator.credentialID, | ||
newCounter | ||
) | ||
} catch (e: any) { | ||
throw new AdapterError( | ||
`Failed to update authenticator counter. This may cause future authentication attempts to fail. ${JSON.stringify({ | ||
credentialID, | ||
oldCounter: authenticator.counter, | ||
newCounter: authenticationInfo.newCounter, | ||
})}`, e) | ||
`Failed to update authenticator counter. This may cause future authentication attempts to fail. ${JSON.stringify( | ||
{ | ||
credentialID, | ||
oldCounter: authenticator.counter, | ||
newCounter: authenticationInfo.newCounter, | ||
} | ||
)}`, | ||
e | ||
) | ||
} | ||
// Get the account and user | ||
const account = await adapter.getAccount(authenticator.providerAccountId, provider.id) | ||
const account = await adapter.getAccount( | ||
authenticator.providerAccountId, | ||
provider.id | ||
) | ||
if (!account) { | ||
throw new AuthError(`WebAuthn account not found in database: ${JSON.stringify({ credentialID, providerAccountId: authenticator.providerAccountId })}`) | ||
throw new AuthError( | ||
`WebAuthn account not found in database: ${JSON.stringify({ | ||
credentialID, | ||
providerAccountId: authenticator.providerAccountId, | ||
})}` | ||
) | ||
} | ||
@@ -254,5 +318,7 @@ | ||
throw new AuthError( | ||
`WebAuthn user not found in database: ${JSON.stringify( | ||
{ credentialID, providerAccountId: authenticator.providerAccountId, userID: account.userId } | ||
)}` | ||
`WebAuthn user not found in database: ${JSON.stringify({ | ||
credentialID, | ||
providerAccountId: authenticator.providerAccountId, | ||
userID: account.userId, | ||
})}` | ||
) | ||
@@ -270,9 +336,17 @@ } | ||
request: RequestInternal, | ||
resCookies: Cookie[], | ||
): Promise<{ account: Account, user: User; authenticator: Authenticator }> { | ||
resCookies: Cookie[] | ||
): Promise<{ account: Account; user: User; authenticator: Authenticator }> { | ||
const { provider } = options | ||
// Get WebAuthn response from request body | ||
const data = request.body && typeof request.body.data === "string" ? JSON.parse(request.body.data) as unknown : undefined | ||
if (!data || typeof data !== "object" || !("id" in data) || typeof data.id !== "string") { | ||
const data = | ||
request.body && typeof request.body.data === "string" | ||
? (JSON.parse(request.body.data) as unknown) | ||
: undefined | ||
if ( | ||
!data || | ||
typeof data !== "object" || | ||
!("id" in data) || | ||
typeof data.id !== "string" | ||
) { | ||
throw new AuthError("Invalid WebAuthn Registration response.") | ||
@@ -282,5 +356,8 @@ } | ||
// Get challenge from request cookies | ||
const { challenge: expectedChallenge, registerData: user } = await webauthnChallenge.use(options, request.cookies, resCookies) | ||
const { challenge: expectedChallenge, registerData: user } = | ||
await webauthnChallenge.use(options, request.cookies, resCookies) | ||
if (!user) { | ||
throw new AuthError("Missing user registration data in WebAuthn challenge cookie.") | ||
throw new AuthError( | ||
"Missing user registration data in WebAuthn challenge cookie." | ||
) | ||
} | ||
@@ -305,3 +382,5 @@ | ||
if (!verification.verified || !verification.registrationInfo) { | ||
throw new WebAuthnVerificationError("WebAuthn registration response could not be verified.") | ||
throw new WebAuthnVerificationError( | ||
"WebAuthn registration response could not be verified." | ||
) | ||
} | ||
@@ -321,6 +400,11 @@ | ||
credentialID: toBase64(verification.registrationInfo.credentialID), | ||
credentialPublicKey: toBase64(verification.registrationInfo.credentialPublicKey), | ||
credentialPublicKey: toBase64( | ||
verification.registrationInfo.credentialPublicKey | ||
), | ||
credentialBackedUp: verification.registrationInfo.credentialBackedUp, | ||
credentialDeviceType: verification.registrationInfo.credentialDeviceType, | ||
transports: transportsToString((data as RegistrationResponseJSON).response.transports as AuthenticatorTransport[]) | ||
transports: transportsToString( | ||
(data as RegistrationResponseJSON).response | ||
.transports as AuthenticatorTransport[] | ||
), | ||
} | ||
@@ -336,6 +420,5 @@ | ||
/** | ||
* Generates WebAuthn authentication options. | ||
* | ||
* | ||
* @param options - The internal options for WebAuthn. | ||
@@ -346,9 +429,14 @@ * @param request - The request object. | ||
*/ | ||
async function getAuthenticationOptions(options: InternalOptionsWebAuthn, request: RequestInternal, user?: User) { | ||
async function getAuthenticationOptions( | ||
options: InternalOptionsWebAuthn, | ||
request: RequestInternal, | ||
user?: User | ||
) { | ||
const { provider, adapter } = options | ||
// Get the user's authenticators. | ||
const authenticators = user && user["id"] ? | ||
await adapter.listAuthenticatorsByUserId(user.id) : | ||
null | ||
const authenticators = | ||
user && user["id"] | ||
? await adapter.listAuthenticatorsByUserId(user.id) | ||
: null | ||
@@ -369,6 +457,5 @@ const relayingParty = provider.getRelayingParty(options, request) | ||
/** | ||
* Generates WebAuthn registration options. | ||
* | ||
* | ||
* @param options - The internal options for WebAuthn. | ||
@@ -387,3 +474,5 @@ * @param request - The request object. | ||
// Get the user's authenticators. | ||
const authenticators = user["id"] ? await adapter.listAuthenticatorsByUserId(user.id) : null | ||
const authenticators = user["id"] | ||
? await adapter.listAuthenticatorsByUserId(user.id) | ||
: null | ||
@@ -414,9 +503,10 @@ // Generate a random user ID for the credential. | ||
export function assertInternalOptionsWebAuthn(options: InternalOptions): InternalOptionsWebAuthn { | ||
export function assertInternalOptionsWebAuthn( | ||
options: InternalOptions | ||
): InternalOptionsWebAuthn { | ||
const { provider, adapter } = options | ||
// Adapter is required for WebAuthn | ||
if (!adapter) throw new MissingAdapter( | ||
"An adapter is required for the WebAuthn provider" | ||
) | ||
if (!adapter) | ||
throw new MissingAdapter("An adapter is required for the WebAuthn provider") | ||
// Provider must be WebAuthn | ||
@@ -430,6 +520,9 @@ if (!provider || provider.type !== "webauthn") { | ||
function fromAdapterAuthenticator(authenticator: AdapterAuthenticator): InternalAuthenticator { | ||
function fromAdapterAuthenticator( | ||
authenticator: AdapterAuthenticator | ||
): InternalAuthenticator { | ||
return { | ||
...authenticator, | ||
credentialDeviceType: authenticator.credentialDeviceType as InternalAuthenticator["credentialDeviceType"], | ||
credentialDeviceType: | ||
authenticator.credentialDeviceType as InternalAuthenticator["credentialDeviceType"], | ||
transports: stringToTransports(authenticator.transports), | ||
@@ -449,8 +542,14 @@ credentialID: fromBase64(authenticator.credentialID), | ||
export function transportsToString(transports: InternalAuthenticator["transports"]) { | ||
export function transportsToString( | ||
transports: InternalAuthenticator["transports"] | ||
) { | ||
return transports?.join(",") | ||
} | ||
export function stringToTransports(tstring: string | undefined): InternalAuthenticator["transports"] { | ||
return tstring ? tstring.split(",") as InternalAuthenticator["transports"] : undefined | ||
export function stringToTransports( | ||
tstring: string | undefined | ||
): InternalAuthenticator["transports"] { | ||
return tstring | ||
? (tstring.split(",") as InternalAuthenticator["transports"]) | ||
: undefined | ||
} |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth" | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth.js" | ||
@@ -14,0 +14,0 @@ /** [Get a user](https://api.mattermost.com/#tag/users/operation/GetUser) */ |
@@ -12,3 +12,3 @@ /** | ||
import type { OAuthConfig, OAuthUserConfig } from "." | ||
import type { OAuthConfig, OAuthUserConfig } from "./oauth.js" | ||
@@ -15,0 +15,0 @@ export interface Person extends Record<string, any> { |
@@ -12,3 +12,6 @@ /** | ||
import WebAuthn, { WebAuthnConfig, DEFAULT_WEBAUTHN_TIMEOUT } from "./webauthn" | ||
import WebAuthn, { | ||
WebAuthnConfig, | ||
DEFAULT_WEBAUTHN_TIMEOUT, | ||
} from "./webauthn.js" | ||
@@ -15,0 +18,0 @@ /** |
@@ -9,3 +9,3 @@ import { | ||
import type { CommonProviderOptions, CredentialInput } from "." | ||
import type { CommonProviderOptions, CredentialInput } from "./index.js" | ||
import type { | ||
@@ -12,0 +12,0 @@ GenerateRegistrationOptionsOpts, |
@@ -12,3 +12,3 @@ /** | ||
import { OAuthConfig, OAuthUserConfig } from "." | ||
import { OAuthConfig, OAuthUserConfig } from "./oauth.js" | ||
@@ -15,0 +15,0 @@ /** |
@@ -79,3 +79,3 @@ /** | ||
WebAuthnProviderType, | ||
} from "./providers/webauthn" | ||
} from "./providers/webauthn.js" | ||
@@ -87,3 +87,6 @@ export type { AuthConfig } from "./index.js" | ||
export type SemverString = `v${number}` | `v${number}.${number}` | `v${number}.${number}.${number}` | ||
export type SemverString = | ||
| `v${number}` | ||
| `v${number}.${number}` | ||
| `v${number}.${number}.${number}` | ||
@@ -455,3 +458,3 @@ /** | ||
/** The active session of the logged in user. */ | ||
export interface Session extends DefaultSession { } | ||
export interface Session extends DefaultSession {} | ||
@@ -476,14 +479,14 @@ /** | ||
: T extends "oidc" | ||
? OIDCConfigInternal<any> | ||
: T extends "email" | ||
? EmailConfig | ||
: T extends "credentials" | ||
? CredentialsConfig | ||
: T extends WebAuthnProviderType | ||
? WebAuthnConfig | ||
: never) & { | ||
signinUrl: string | ||
/** @example `"https://example.com/api/auth/callback/id"` */ | ||
callbackUrl: string | ||
} | ||
? OIDCConfigInternal<any> | ||
: T extends "email" | ||
? EmailConfig | ||
: T extends "credentials" | ||
? CredentialsConfig | ||
: T extends WebAuthnProviderType | ||
? WebAuthnConfig | ||
: never) & { | ||
signinUrl: string | ||
/** @example `"https://example.com/api/auth/callback/id"` */ | ||
callbackUrl: string | ||
} | ||
@@ -633,4 +636,4 @@ export interface PublicProvider { | ||
isOnRedirectProxy: boolean | ||
experimental: NonNullable<AuthConfig['experimental']> | ||
experimental: NonNullable<AuthConfig["experimental"]> | ||
basePath: string | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1521986
38384