diff --git a/.changeset/sign-in-flow-limits.md b/.changeset/sign-in-flow-limits.md new file mode 100644 index 00000000..fb9c9892 --- /dev/null +++ b/.changeset/sign-in-flow-limits.md @@ -0,0 +1,10 @@ +--- +'seamless-auth-api': patch +--- + +Tightens three sign-in flows. + +- `POST /webauthn/login/start` and `POST /webauthn/login/finish` are now rate limited per attempt (10 per window) and per address (ten times `flow_rate_limits.otp.perIp`, 100 by default). `GET /magic-link/check` is limited per attempt (300 per window, enough to poll every few seconds for the whole life of a link). These use the `flow_rate_limits` window. Before, only the global limiter applied. No cap spans an account's attempts: a pre-auth token comes from an address alone, so a stranger could spend that cap to block the owner. +- A passkey sign-in start that matches no credential on the account is now recorded as `webauthn_login_failed` instead of `login_failed`, so it no longer counts toward account lockout. Anyone holding a pre-auth token for an address could otherwise lock its owner out by asking for a credential id the account does not have. +- Issuing a WebAuthn challenge now deletes the user's spent and expired challenge rows. Before, every ceremony start left a row behind permanently. +- OAuth sign-in now refuses an account whose `revoked` flag is set, answering 403 `login_method_disabled`, before claiming or linking it. It was the one sign-in route that did not check the flag. diff --git a/openapi.json b/openapi.json index 4955a6a7..4fb1d3fc 100644 --- a/openapi.json +++ b/openapi.json @@ -17752,7 +17752,7 @@ "/oauth/{providerId}/callback": { "post": { "summary": "Finish OAuth login", - "description": "Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`.", + "description": "Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has been revoked or has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`.", "tags": ["OAuth"], "parameters": [ { diff --git a/src/controllers/oauth.ts b/src/controllers/oauth.ts index 4c0568de..175f2f01 100644 --- a/src/controllers/oauth.ts +++ b/src/controllers/oauth.ts @@ -22,6 +22,7 @@ import { getEnabledOAuthProviders, getOAuthProvider, isOidcProvider, + OAuthAccountRevokedError, OAuthProfileError, oauthProfileFromIdToken, OAuthProviderRetiredError, @@ -220,6 +221,19 @@ export async function finishOAuthLogin(req: RouteRequest, res: Response) { }, }); } catch (error) { + if (error instanceof OAuthAccountRevokedError) { + await AuthEventService.log({ + userId: error.userId, + type: 'oauth_login_failed', + req, + metadata: { providerId: provider.id, reason: 'account_revoked' }, + }); + + // Answered like the other refusals of an account that may not use this method, which + // keeps the response contract and the OAuth error codes unchanged. + return res.status(403).json({ error: 'login_method_disabled' }); + } + if (error instanceof OAuthProviderRetiredError) { await AuthEventService.log({ userId: error.userId, diff --git a/src/controllers/webauthn.ts b/src/controllers/webauthn.ts index 96e9ca79..75758ce0 100644 --- a/src/controllers/webauthn.ts +++ b/src/controllers/webauthn.ts @@ -464,7 +464,7 @@ const generateWebAuthn = async (req: Request, res: Response) => { if (!authReq.attemptId) { await AuthEventService.log({ userId: user.id, - type: 'login_failed', + type: 'webauthn_login_failed', req, metadata: { reason: 'Ephemeral token has no attempt id' }, }); @@ -480,9 +480,11 @@ const generateWebAuthn = async (req: Request, res: Response) => { }); if (!assertionCredentials || assertionCredentials.length === 0) { + // Not a lockout failure: anyone holding a pre-auth token for the address can ask for a + // credential id the account does not have, and must not be able to lock it out by doing so. await AuthEventService.log({ userId: user.id, - type: 'login_failed', + type: 'webauthn_login_failed', req, metadata: { reason: prf ? 'No PRF-capable credentials' : 'No credentials' }, }); diff --git a/src/generated/api.ts b/src/generated/api.ts index 1d54d40c..eb56a978 100644 --- a/src/generated/api.ts +++ b/src/generated/api.ts @@ -16572,7 +16572,7 @@ export interface paths { put?: never; /** * Finish OAuth login - * @description Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`. + * @description Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has been revoked or has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`. */ post: { parameters: { diff --git a/src/middleware/rateLimit.ts b/src/middleware/rateLimit.ts index aa6e0f75..add3ced8 100644 --- a/src/middleware/rateLimit.ts +++ b/src/middleware/rateLimit.ts @@ -228,3 +228,41 @@ const sessionExchangeCachedLimiter = createFlowLimiter( export function sessionExchangeLimiter(req: Request, res: Response, next: NextFunction) { return sessionExchangeCachedLimiter(req, res, next); } + +// Per attempt only, with no cap across one account's attempts. A pre-auth token comes from an +// address alone, so an account-wide cap is one a stranger can spend to lock the owner out of the +// sign-in. A client polls a magic link every few seconds for as long as the link lives (fifteen +// minutes); a passkey sign-in starts and finishes once, with retries for a cancelled prompt. +const MAGIC_LINK_CHECKS_PER_WINDOW_PER_ATTEMPT = 300; +const WEBAUTHN_LOGINS_PER_WINDOW_PER_ATTEMPT = 10; +// What bounds a caller minting fresh attempts. A multiple of the configured OTP per-address +// limit, so a deployment that raised that for a carrier NAT raises this with it. +export const WEBAUTHN_ADDRESS_MULTIPLIER = 10; + +function getSubjectOrAddressKey(req: Request) { + return subjectKey(req) ?? `ip:${clientAddressKey(req)}`; +} + +const magicLinkCheckCachedLimiter = createFlowLimiter( + () => MAGIC_LINK_CHECKS_PER_WINDOW_PER_ATTEMPT, + withAttempt(getSubjectOrAddressKey), +); +const webauthnLoginIpCachedLimiter = createFlowLimiter( + (limits) => limits.otp.perIp * WEBAUTHN_ADDRESS_MULTIPLIER, +); +const webauthnLoginIdentityCachedLimiter = createFlowLimiter( + () => WEBAUTHN_LOGINS_PER_WINDOW_PER_ATTEMPT, + withAttempt(getSubjectOrAddressKey), +); + +export function magicLinkCheckLimiter(req: Request, res: Response, next: NextFunction) { + return magicLinkCheckCachedLimiter(req, res, next); +} + +export function webauthnLoginIpLimiter(req: Request, res: Response, next: NextFunction) { + return webauthnLoginIpCachedLimiter(req, res, next); +} + +export function webauthnLoginIdentityLimiter(req: Request, res: Response, next: NextFunction) { + return webauthnLoginIdentityCachedLimiter(req, res, next); +} diff --git a/src/routes/magicLink.routes.ts b/src/routes/magicLink.routes.ts index 37508513..6f4c3d0f 100644 --- a/src/routes/magicLink.routes.ts +++ b/src/routes/magicLink.routes.ts @@ -12,7 +12,11 @@ import { verifyMagicLink, } from '../controllers/magicLinks.js'; import { createRouter } from '../lib/createRouter.js'; -import { magicLinkEmailLimiter, magicLinkIpLimiter } from '../middleware/rateLimit.js'; +import { + magicLinkCheckLimiter, + magicLinkEmailLimiter, + magicLinkIpLimiter, +} from '../middleware/rateLimit.js'; import { ErrorSchema, InternalErrorSchema, MessageSchema } from '../schemas/generic.responses.js'; import { MagicLinkConfirmBodySchema, @@ -83,6 +87,7 @@ magicLinkRouter.get( summary: 'Poll for magic link confirmation', decoy: decoyPollMagicLink, tags: ['MagicLinks'], + middleware: [magicLinkCheckLimiter], schemas: { response: { diff --git a/src/routes/oauth.routes.ts b/src/routes/oauth.routes.ts index a3149dba..45e1cb64 100644 --- a/src/routes/oauth.routes.ts +++ b/src/routes/oauth.routes.ts @@ -63,7 +63,7 @@ oauthRouter.post( adapter: { issues: 'session' }, summary: 'Finish OAuth login', description: - "Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`.", + "Answers 403 with `code: oauth_provider_retired` when an organization the user belongs to has retired this provider, and 403 `login_method_disabled` when the account has been revoked or has to sign in with a passkey (phishing-resistant-only mode, or the account holds a passkey and `passkey_login_fallback_enabled` is off). A success carries `nextStep: enroll_passkey` when the provider has `promptPasskeyEnrollment` set and the user has no passkey yet. A login hook can refuse the sign-in: 403 `login_denied` with the hook's `message`, or 503 `login_hook_unavailable`.", tags: ['OAuth'], middleware: [oauthIpLimiter, oauthProviderLimiter], schemas: { diff --git a/src/routes/webauthn.routes.ts b/src/routes/webauthn.routes.ts index 904ae99e..885d5cd6 100644 --- a/src/routes/webauthn.routes.ts +++ b/src/routes/webauthn.routes.ts @@ -15,6 +15,7 @@ import { verifyWebAuthnRegistration, } from '../controllers/webauthn.js'; import { createRouter } from '../lib/createRouter.js'; +import { webauthnLoginIdentityLimiter, webauthnLoginIpLimiter } from '../middleware/rateLimit.js'; import { requireFactorEnrollmentProof } from '../middleware/requireFactorEnrollmentProof.js'; import { CredentialUpdateResponseSchema } from '../schemas/credential.responses.js'; import { ErrorSchema, InternalErrorSchema } from '../schemas/generic.responses.js'; @@ -98,6 +99,7 @@ webauthnRouter.post( summary: 'Start WebAuthn login', decoy: decoyStartWebAuthnLogin, tags: ['WebAuthn'], + middleware: [webauthnLoginIpLimiter, webauthnLoginIdentityLimiter], schemas: { body: WebAuthnAssertionStartSchema, @@ -121,6 +123,7 @@ webauthnRouter.post( summary: 'Finish WebAuthn login', decoy: decoyFinishWebAuthnLogin, tags: ['WebAuthn'], + middleware: [webauthnLoginIpLimiter, webauthnLoginIdentityLimiter], schemas: { body: WebAuthnLoginFinishSchema, diff --git a/src/services/oauthService.ts b/src/services/oauthService.ts index a47e27f0..4fe209e4 100644 --- a/src/services/oauthService.ts +++ b/src/services/oauthService.ts @@ -118,6 +118,26 @@ export class OAuthProviderRetiredError extends Error { } } +/** + * A revoked account signs in through no route, and OAuth was the one that did not check. An + * adapter that verifies access tokens locally would accept one minted here until it expired. + */ +export class OAuthAccountRevokedError extends Error { + readonly userId: string; + + constructor(userId: string) { + super('This account cannot sign in'); + this.name = 'OAuthAccountRevokedError'; + this.userId = userId; + } +} + +function assertNotRevoked(user: User) { + if (user.revoked) { + throw new OAuthAccountRevokedError(user.id); + } +} + async function assertProviderNotRetired(provider: OAuthProviderConfig, user: User) { const retiring = await findOrganizationsRetiringOAuthProvider(user.id, provider.id); @@ -836,6 +856,7 @@ export async function resolveOAuthUser(provider: OAuthProviderConfig, profile: O if (existingIdentity) { const user = await User.findByPk(existingIdentity.userId); if (user) { + assertNotRevoked(user); await assertProviderNotRetired(provider, user); return user; } @@ -852,6 +873,7 @@ export async function resolveOAuthUser(provider: OAuthProviderConfig, profile: O if (imported) { // Before claiming or linking, so a refused sign-in leaves the account as it was. + assertNotRevoked(imported); await assertProviderNotRetired(provider, imported); await claimUnverifiedAccount(imported, profile.emailVerified === true); await linkOAuthIdentity(provider, profile, imported); @@ -881,6 +903,7 @@ export async function resolveOAuthUser(provider: OAuthProviderConfig, profile: O } if (user) { + assertNotRevoked(user); await assertProviderNotRetired(provider, user); await claimUnverifiedAccount(user, true); } else { diff --git a/src/services/webauthnChallengeService.ts b/src/services/webauthnChallengeService.ts index e09f0255..3413d869 100644 --- a/src/services/webauthnChallengeService.ts +++ b/src/services/webauthnChallengeService.ts @@ -47,6 +47,7 @@ export async function issueChallenge(params: { const now = params.now ?? new Date(); await consumeOutstanding(params.userId, params.purpose, params.attemptId, now); + await collectSpentChallenges(params.userId, now); return WebAuthnChallenge.create({ userId: params.userId, @@ -138,3 +139,14 @@ async function consumeOutstanding( }, ); } + +// A row is only read while it is live, so spent and expired ones are dropped as the user's next +// challenge is issued. Without this every ceremony start left a row behind for good. +async function collectSpentChallenges(userId: string, now: Date) { + await WebAuthnChallenge.destroy({ + where: { + userId, + [Op.or]: [{ consumedAt: { [Op.ne]: null } }, { expiresAt: { [Op.lte]: now } }], + }, + }); +} diff --git a/tests/integration/oauth/oauth.spec.ts b/tests/integration/oauth/oauth.spec.ts index 1c7f6002..f0baa2c9 100644 --- a/tests/integration/oauth/oauth.spec.ts +++ b/tests/integration/oauth/oauth.spec.ts @@ -955,6 +955,39 @@ describe('OAuth routes', () => { ); }); + it('refuses a revoked account that matches by email, before claiming or linking', async () => { + const user = buildUser({ id: 'user-1', phone: null, verified: false, revoked: true }); + (User.findOne as any).mockResolvedValue(user); + + const res = await finishGoogleSignIn(); + + expect(res.status).toBe(403); + expect(res.body).toEqual({ error: 'login_method_disabled' }); + expect(OAuthIdentity.findOrCreate).not.toHaveBeenCalled(); + expect(user.update).not.toHaveBeenCalled(); + expect(Session.create).not.toHaveBeenCalled(); + expect(AuthEventService.log).toHaveBeenCalledWith( + expect.objectContaining({ + type: 'oauth_login_failed', + userId: 'user-1', + metadata: expect.objectContaining({ reason: 'account_revoked' }), + }), + ); + }); + + it('refuses a revoked account whose identity is already linked', async () => { + (OAuthIdentity.findOne as any).mockResolvedValue({ userId: 'user-1' }); + (User.findByPk as any).mockResolvedValue( + buildUser({ id: 'user-1', phone: null, revoked: true }), + ); + + const res = await finishGoogleSignIn(); + + expect(res.status).toBe(403); + expect(res.body).toEqual({ error: 'login_method_disabled' }); + expect(Session.create).not.toHaveBeenCalled(); + }); + it('refuses a returning user whose identity is already linked', async () => { (OAuthIdentity.findOne as any).mockResolvedValue({ userId: 'user-1' }); (User.findByPk as any).mockResolvedValue(buildUser({ id: 'user-1', phone: null })); diff --git a/tests/integration/rateLimit/identityFlowLimits.spec.ts b/tests/integration/rateLimit/identityFlowLimits.spec.ts index 1cad692f..37a07fef 100644 --- a/tests/integration/rateLimit/identityFlowLimits.spec.ts +++ b/tests/integration/rateLimit/identityFlowLimits.spec.ts @@ -13,7 +13,14 @@ type IdentityLimiter = (req: Request, res: Response, next: NextFunction) => unkn * Mounts one identity limiter behind a stand-in for bearer auth, which is what sets the * user and the attempt on a real ephemeral route before route middleware runs. */ -async function appWith(name: 'otpIdentityLimiter' | 'magicLinkEmailLimiter') { +async function appWith( + name: + | 'otpIdentityLimiter' + | 'magicLinkEmailLimiter' + | 'magicLinkCheckLimiter' + | 'webauthnLoginIdentityLimiter' + | 'webauthnLoginIpLimiter', +) { vi.resetModules(); const limiters = await import('../../../src/middleware/rateLimit.js'); const limiter = limiters[name] as IdentityLimiter; @@ -120,3 +127,69 @@ describe.each(['otpIdentityLimiter', 'magicLinkEmailLimiter'] as const)('%s', (n expect(await status(app, 'owner@example.com', 'owner')).toBe(200); }); }); + +// Fixed per-attempt allowances, not flow_rate_limits keys: a new key there needs a types release. +describe.each([ + ['magicLinkCheckLimiter', 300], + ['webauthnLoginIdentityLimiter', 10], +] as const)('%s', (name, perAttempt) => { + it('refuses an attempt past its allowance and leaves another attempt its own', async () => { + const app = await appWith(name); + + for (let i = 0; i < perAttempt; i++) { + expect(await status(app, 'owner@example.com', 'attempt-a')).toBe(200); + } + + expect(await status(app, 'owner@example.com', 'attempt-a')).toBe(429); + expect(await status(app, 'owner@example.com', 'attempt-b')).toBe(200); + }); + + // A pre-auth token comes from an address alone, so a cap across an account's attempts is + // one a stranger can spend to keep the owner from signing in. + it("leaves the owner's attempt untouched however many attempts a stranger spends", async () => { + const app = await appWith(name); + + for (let attempt = 0; attempt < 5; attempt++) { + for (let i = 0; i <= perAttempt; i++) { + await send(app, 'owner@example.com', `stranger-${attempt}`); + } + } + + expect(await status(app, 'owner@example.com', 'owner')).toBe(200); + }); + + it('falls back to the requester address without a subject or attempt', async () => { + vi.resetModules(); + const limiters = await import('../../../src/middleware/rateLimit.js'); + const app = express(); + app.post('/flow', limiters[name] as IdentityLimiter, (_req, res) => { + res.status(200).json({ ok: true }); + }); + + for (let i = 0; i < perAttempt; i++) { + await request(app).post('/flow'); + } + + expect((await request(app).post('/flow')).status).toBe(429); + }); +}); + +describe('webauthnLoginIpLimiter', () => { + it('caps one address across subjects at a multiple of the OTP per-address limit', async () => { + (getSystemConfig as ReturnType).mockResolvedValue({ + flow_rate_limits: { + windowSeconds: 900, + otp: { perIp: 2, perIdentity: 5 }, + magicLink: { perIp: 20, perIdentity: 5 }, + oauth: { perIp: 30, perProvider: 10 }, + }, + }); + const app = await appWith('webauthnLoginIpLimiter'); + + for (let i = 0; i < 20; i++) { + expect(await status(app, `user-${i}@example.com`, `attempt-${i}`)).toBe(200); + } + + expect(await status(app, 'another@example.com', 'attempt-x')).toBe(429); + }); +}); diff --git a/tests/integration/webauthn/webauthn.spec.ts b/tests/integration/webauthn/webauthn.spec.ts index 6f72ffee..fffef105 100644 --- a/tests/integration/webauthn/webauthn.spec.ts +++ b/tests/integration/webauthn/webauthn.spec.ts @@ -19,6 +19,7 @@ import { generateRefreshToken, signAccessToken } from '../../../src/lib/token'; import { AuthEvent } from '../../../src/models/authEvents'; import { AuthFailure } from '../../../src/models/authFailures'; import { AuthEventService } from '../../../src/services/authEventService'; +import { isLockoutFailureType } from '../../../src/services/authFailureCounter'; import { generateWebAuthn, registerWebAuthn, @@ -1169,6 +1170,25 @@ describe('POST /webauthn/login/start', () => { expect(res.status).toBe(401); }); + // The pre-auth token comes from an address alone, and anyone can ask for a credential id the + // account does not have. Counted toward lockout, that let a stranger lock the owner out. + it('records a refused start as a passkey failure that does not count toward lockout', async () => { + (Credential.findAll as any).mockResolvedValue([buildCredential()]); + + await request(app).post('/webauthn/login/start').send({ credentialId: 'not-on-the-account' }); + + expect(AuthEventService.log).toHaveBeenCalledWith( + expect.objectContaining({ + type: 'webauthn_login_failed', + metadata: { reason: 'No credentials' }, + }), + ); + expect(isLockoutFailureType('webauthn_login_failed')).toBe(false); + expect(AuthEventService.log).not.toHaveBeenCalledWith( + expect.objectContaining({ type: 'login_failed' }), + ); + }); + it('returns challenge', async () => { (Credential.findAll as any).mockResolvedValue([buildCredential()]); diff --git a/tests/setup/mocks.ts b/tests/setup/mocks.ts index 7d91b11e..a2afeefe 100644 --- a/tests/setup/mocks.ts +++ b/tests/setup/mocks.ts @@ -368,6 +368,9 @@ vi.mock('../../src/middleware/requireAdmin.js', () => ({ vi.mock('../../src/middleware/rateLimit.js', () => ({ magicLinkIpLimiter: (_req: any, _res: any, next: any) => next(), magicLinkEmailLimiter: (_req: any, _res: any, next: any) => next(), + magicLinkCheckLimiter: (_req: any, _res: any, next: any) => next(), + webauthnLoginIpLimiter: (_req: any, _res: any, next: any) => next(), + webauthnLoginIdentityLimiter: (_req: any, _res: any, next: any) => next(), oauthIpLimiter: (_req: any, _res: any, next: any) => next(), oauthProviderLimiter: (_req: any, _res: any, next: any) => next(), sessionExchangeLimiter: (_req: any, _res: any, next: any) => next(), diff --git a/tests/unit/services/webauthnChallengeService.spec.ts b/tests/unit/services/webauthnChallengeService.spec.ts index 62d57775..49489625 100644 --- a/tests/unit/services/webauthnChallengeService.spec.ts +++ b/tests/unit/services/webauthnChallengeService.spec.ts @@ -1,3 +1,4 @@ +import { Op } from 'sequelize'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { WebAuthnChallenge } from '../../../src/models/webauthnChallenges'; @@ -36,6 +37,23 @@ describe('issueChallenge', () => { }); }); + // Only a live row is ever read, and every start used to leave one behind for good. + it("drops the user's spent and expired challenges", async () => { + (WebAuthnChallenge.create as any).mockResolvedValue({}); + + await issueChallenge({ userId: 'user-1', purpose: 'login', challenge: 'abc', now: NOW }); + + expect(WebAuthnChallenge.destroy).toHaveBeenCalledWith({ + where: { + userId: 'user-1', + [Op.or]: [{ consumedAt: { [Op.ne]: null } }, { expiresAt: { [Op.lte]: NOW } }], + }, + }); + expect((WebAuthnChallenge.destroy as any).mock.invocationCallOrder[0]).toBeLessThan( + (WebAuthnChallenge.create as any).mock.invocationCallOrder[0], + ); + }); + it('spends anything still outstanding for the same flow', async () => { (WebAuthnChallenge.create as any).mockResolvedValue({});