feat(api): add authenticators api (#2124)
* feat(api): add authenticators api * fix(services): responses interpreting in authenticator manager
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { HttpServiceInterface } from '../../Http/HttpServiceInterface'
|
||||
import {
|
||||
ListAuthenticatorsRequestParams,
|
||||
DeleteAuthenticatorRequestParams,
|
||||
GenerateAuthenticatorRegistrationOptionsRequestParams,
|
||||
VerifyAuthenticatorRegistrationResponseRequestParams,
|
||||
GenerateAuthenticatorAuthenticationOptionsRequestParams,
|
||||
VerifyAuthenticatorAuthenticationResponseRequestParams,
|
||||
} from '../../Request'
|
||||
import {
|
||||
ListAuthenticatorsResponse,
|
||||
DeleteAuthenticatorResponse,
|
||||
GenerateAuthenticatorRegistrationOptionsResponse,
|
||||
VerifyAuthenticatorRegistrationResponseResponse,
|
||||
GenerateAuthenticatorAuthenticationOptionsResponse,
|
||||
VerifyAuthenticatorAuthenticationResponseResponse,
|
||||
} from '../../Response'
|
||||
import { AuthenticatorServerInterface } from './AuthenticatorServerInterface'
|
||||
import { Paths } from './Paths'
|
||||
|
||||
export class AuthenticatorServer implements AuthenticatorServerInterface {
|
||||
constructor(private httpService: HttpServiceInterface) {}
|
||||
|
||||
async list(params: ListAuthenticatorsRequestParams): Promise<ListAuthenticatorsResponse> {
|
||||
const response = await this.httpService.get(Paths.v1.listAuthenticators, params)
|
||||
|
||||
return response as ListAuthenticatorsResponse
|
||||
}
|
||||
|
||||
async delete(params: DeleteAuthenticatorRequestParams): Promise<DeleteAuthenticatorResponse> {
|
||||
const response = await this.httpService.delete(Paths.v1.deleteAuthenticator(params.authenticatorId), params)
|
||||
|
||||
return response as DeleteAuthenticatorResponse
|
||||
}
|
||||
|
||||
async generateRegistrationOptions(
|
||||
params: GenerateAuthenticatorRegistrationOptionsRequestParams,
|
||||
): Promise<GenerateAuthenticatorRegistrationOptionsResponse> {
|
||||
const response = await this.httpService.get(Paths.v1.generateRegistrationOptions, params)
|
||||
|
||||
return response as GenerateAuthenticatorRegistrationOptionsResponse
|
||||
}
|
||||
|
||||
async verifyRegistrationResponse(
|
||||
params: VerifyAuthenticatorRegistrationResponseRequestParams,
|
||||
): Promise<VerifyAuthenticatorRegistrationResponseResponse> {
|
||||
const response = await this.httpService.post(Paths.v1.verifyRegistrationResponse, params)
|
||||
|
||||
return response as VerifyAuthenticatorRegistrationResponseResponse
|
||||
}
|
||||
|
||||
async generateAuthenticationOptions(
|
||||
params: GenerateAuthenticatorAuthenticationOptionsRequestParams,
|
||||
): Promise<GenerateAuthenticatorAuthenticationOptionsResponse> {
|
||||
const response = await this.httpService.get(Paths.v1.generateAuthenticationOptions, params)
|
||||
|
||||
return response as GenerateAuthenticatorAuthenticationOptionsResponse
|
||||
}
|
||||
|
||||
async verifyAuthenticationResponse(
|
||||
params: VerifyAuthenticatorAuthenticationResponseRequestParams,
|
||||
): Promise<VerifyAuthenticatorAuthenticationResponseResponse> {
|
||||
const response = await this.httpService.post(Paths.v1.verifyAuthenticationResponse, params)
|
||||
|
||||
return response as VerifyAuthenticatorAuthenticationResponseResponse
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
ListAuthenticatorsRequestParams,
|
||||
DeleteAuthenticatorRequestParams,
|
||||
GenerateAuthenticatorRegistrationOptionsRequestParams,
|
||||
VerifyAuthenticatorRegistrationResponseRequestParams,
|
||||
GenerateAuthenticatorAuthenticationOptionsRequestParams,
|
||||
VerifyAuthenticatorAuthenticationResponseRequestParams,
|
||||
} from '../../Request'
|
||||
import {
|
||||
ListAuthenticatorsResponse,
|
||||
DeleteAuthenticatorResponse,
|
||||
GenerateAuthenticatorRegistrationOptionsResponse,
|
||||
VerifyAuthenticatorRegistrationResponseResponse,
|
||||
GenerateAuthenticatorAuthenticationOptionsResponse,
|
||||
VerifyAuthenticatorAuthenticationResponseResponse,
|
||||
} from '../../Response'
|
||||
|
||||
export interface AuthenticatorServerInterface {
|
||||
list(params: ListAuthenticatorsRequestParams): Promise<ListAuthenticatorsResponse>
|
||||
delete(params: DeleteAuthenticatorRequestParams): Promise<DeleteAuthenticatorResponse>
|
||||
generateRegistrationOptions(
|
||||
params: GenerateAuthenticatorRegistrationOptionsRequestParams,
|
||||
): Promise<GenerateAuthenticatorRegistrationOptionsResponse>
|
||||
verifyRegistrationResponse(
|
||||
params: VerifyAuthenticatorRegistrationResponseRequestParams,
|
||||
): Promise<VerifyAuthenticatorRegistrationResponseResponse>
|
||||
generateAuthenticationOptions(
|
||||
params: GenerateAuthenticatorAuthenticationOptionsRequestParams,
|
||||
): Promise<GenerateAuthenticatorAuthenticationOptionsResponse>
|
||||
verifyAuthenticationResponse(
|
||||
params: VerifyAuthenticatorAuthenticationResponseRequestParams,
|
||||
): Promise<VerifyAuthenticatorAuthenticationResponseResponse>
|
||||
}
|
||||
14
packages/api/src/Domain/Server/Authenticator/Paths.ts
Normal file
14
packages/api/src/Domain/Server/Authenticator/Paths.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
const AuthenticatorPaths = {
|
||||
listAuthenticators: '/v1/authenticators',
|
||||
deleteAuthenticator: (authenticatorId: string) => `/v1/authenticators/${authenticatorId}`,
|
||||
generateRegistrationOptions: '/v1/authenticators/generate-registration-options',
|
||||
verifyRegistrationResponse: '/v1/authenticators/verify-registration',
|
||||
generateAuthenticationOptions: '/v1/authenticators/generate-authentication-options',
|
||||
verifyAuthenticationResponse: '/v1/authenticators/verify-authentication',
|
||||
}
|
||||
|
||||
export const Paths = {
|
||||
v1: {
|
||||
...AuthenticatorPaths,
|
||||
},
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
export * from './Authenticator/AuthenticatorServer'
|
||||
export * from './Authenticator/AuthenticatorServerInterface'
|
||||
export * from './Subscription/SubscriptionServer'
|
||||
export * from './Subscription/SubscriptionServerInterface'
|
||||
export * from './User/UserServer'
|
||||
|
||||
Reference in New Issue
Block a user