import { DefaultAppWithUnwrappedScopes } from '@/modules/auth/defaultApps' import { FullServerApp, ServerAppListItem, UserServerApp } from '@/modules/auth/domain/types' import { ScopeRecord } from '@/modules/auth/helpers/types' import { AuthorizationCodeRecord, RefreshTokenRecord } from '@/modules/auth/repositories' import { ServerAppRecord } from '@/modules/core/helpers/types' import { MarkNullableOptional } from '@/modules/shared/helpers/typeHelper' import { Optional, ServerScope } from '@speckle/shared' import { SetOptional } from 'type-fest' import type { Handler } from 'express' import { Strategy, AuthenticateOptions } from 'passport' export type GetApp = (params: { id: string }) => Promise export type GetAllPublicApps = () => Promise export type GetAllAppsCreatedByUser = (params: { userId: string }) => Promise export type GetAllAppsAuthorizedByUser = (params: { userId: string }) => Promise export type GetAllScopes = () => Promise export type RegisterDefaultApp = (app: DefaultAppWithUnwrappedScopes) => Promise export type UpdateDefaultApp = ( app: DefaultAppWithUnwrappedScopes, existingApp: FullServerApp ) => Promise export type CreateApp = ( app: Omit< MarkNullableOptional>, 'id' | 'secret' | 'createdAt' | 'trustByDefault' > & { scopes: ServerScope[] } ) => Promise<{ id: string; secret: string }> export type RevokeExistingAppCredentials = (params: { appId: string }) => Promise export type RevokeExistingAppCredentialsForUser = (params: { appId: string userId: string }) => Promise export type RevokeRefreshToken = (params: { tokenId: string }) => Promise export type UpdateApp = (params: { app: Partial & { id: string } & { scopes?: ServerScope[] } }) => Promise export type DeleteApp = (params: { id: string }) => Promise export type GetAuthorizationCode = (params: { id: string }) => Promise> export type DeleteAuthorizationCode = (params: { id: string }) => Promise export type CreateRefreshToken = (params: { token: SetOptional }) => Promise export type GetRefreshToken = (params: { id: string }) => Promise> export type CreateAuthorizationCode = (params: { appId: string userId: string challenge: string }) => Promise export type DeleteExistingUserAuthTokens = (userId: string) => Promise export type GetAppScopes = ( appIds: string[] ) => Promise<{ [appId: string]: Array<{ name: ServerScope; description: string }> }> export type InitializeDefaultApps = () => Promise export type CreateAppTokenFromAccessCode = (params: { appId: string appSecret: string accessCode: string challenge: string }) => Promise<{ token: string refreshToken: string }> export type PassportAuthenticateHandlerBuilder = ( strategy: Strategy | string, options?: Optional ) => Handler export type GetTokenAppInfo = (params: { token: string appId?: string }) => Promise