// Ambient type declarations for packages that ship without their own types
// and have no @types package. Minimal, scoped to our usage.

declare module 'passport-google-oauth2' {
  import { Strategy as PassportStrategy } from 'passport-strategy';

  interface GoogleStrategyOptions {
    clientID: string;
    clientSecret: string;
    callbackURL: string;
    passReqToCallback?: boolean;
  }

  interface GoogleProfile {
    email?: string;
    [key: string]: unknown;
  }

  type GoogleVerifyCallback = (error: unknown, user?: unknown) => void;

  type GoogleVerifyFunction = (
    request: unknown,
    accessToken: string,
    refreshToken: string,
    profile: GoogleProfile,
    done: GoogleVerifyCallback,
  ) => void;

  export class Strategy extends PassportStrategy {
    constructor(options: GoogleStrategyOptions, verify: GoogleVerifyFunction);
  }
}

declare module 'passport-microsoft' {
  import { Strategy as PassportStrategy } from 'passport-strategy';

  interface MicrosoftStrategyOptions {
    clientID: string;
    clientSecret: string;
    callbackURL: string;
    passReqToCallback?: boolean;
  }

  interface MicrosoftProfile {
    _json: { mail?: string; userPrincipalName?: string };
    [key: string]: unknown;
  }

  type MicrosoftVerifyCallback = (error: unknown, user?: unknown) => void;

  type MicrosoftVerifyFunction = (
    request: unknown,
    accessToken: string,
    refreshToken: string,
    profile: MicrosoftProfile,
    done: MicrosoftVerifyCallback,
  ) => void;

  export class Strategy extends PassportStrategy {
    constructor(
      options: MicrosoftStrategyOptions,
      verify: MicrosoftVerifyFunction,
    );
  }
}
