Skip to content

Commit

Permalink
whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoenig134 committed Dec 12, 2024
1 parent cb5a3f2 commit 54901bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { Result } from "@js-soft/ts-utils";
import { Inject } from "@nmshd/typescript-ioc";
import { TokenDTO } from "../../../types";
import { CreateIdentityRecoveryKitRequest, CreateIdentityRecoveryKitUseCase, DoesIdentityRecoveryKitExistResponse, DoesIdentityRecoveryKitExistUseCase } from "../../../useCases";
import {
CheckForExistingIdentityRecoveryKitResponse,
CheckForExistingIdentityRecoveryKitUseCase,
CreateIdentityRecoveryKitRequest,
CreateIdentityRecoveryKitUseCase
} from "../../../useCases";

export class IdentityRecoveryKitsFacade {
public constructor(
@Inject private readonly createIdentityRecoveryKitUseCase: CreateIdentityRecoveryKitUseCase,
@Inject private readonly existsIdentityRecoveryKitUseCase: DoesIdentityRecoveryKitExistUseCase
@Inject private readonly checkForExistingIdentityRecoveryKitUseCase: CheckForExistingIdentityRecoveryKitUseCase
) {}

public async createIdentityRecoveryKit(request: CreateIdentityRecoveryKitRequest): Promise<Result<TokenDTO>> {
return await this.createIdentityRecoveryKitUseCase.execute(request);
}

public async doesIdentityRecoveryKitExist(): Promise<Result<DoesIdentityRecoveryKitExistResponse>> {
return await this.existsIdentityRecoveryKitUseCase.execute();
public async checkForExistingIdentityRecoveryKit(): Promise<Result<CheckForExistingIdentityRecoveryKitResponse>> {
return await this.checkForExistingIdentityRecoveryKitUseCase.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { DevicesController } from "@nmshd/transport";
import { Inject } from "@nmshd/typescript-ioc";
import { UseCase } from "../../common";

export interface DoesIdentityRecoveryKitExistResponse {
export interface CheckForExistingIdentityRecoveryKitResponse {
exists: boolean;
}

export class DoesIdentityRecoveryKitExistUseCase extends UseCase<void, DoesIdentityRecoveryKitExistResponse> {
export class CheckForExistingIdentityRecoveryKitUseCase extends UseCase<void, CheckForExistingIdentityRecoveryKitResponse> {
public constructor(@Inject private readonly devicesController: DevicesController) {
super();
}

protected async executeInternal(): Promise<Result<DoesIdentityRecoveryKitExistResponse>> {
protected async executeInternal(): Promise<Result<CheckForExistingIdentityRecoveryKitResponse>> {
const devices = await this.devicesController.list();

return Result.ok({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./CheckForExistingIdentityRecoveryKit";
export * from "./CreateIdentityRecoveryKit";
export * from "./DoesIdentityRecoveryKitExist";
4 changes: 2 additions & 2 deletions packages/runtime/test/transport/identityRecoveryKits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("Identity Recovery Kits", () => {
});

test("should tell that no recovery kit exists", async () => {
const response = await services.transport.identityRecoveryKits.doesIdentityRecoveryKitExist();
const response = await services.transport.identityRecoveryKits.checkForExistingIdentityRecoveryKit();
expect(response).toBeSuccessful();

expect(response.value.exists).toBe(false);
Expand All @@ -83,7 +83,7 @@ describe("Identity Recovery Kits", () => {
test("should tell that a recovery kit exists", async () => {
await services.transport.identityRecoveryKits.createIdentityRecoveryKit({ profileName: "profileName", passwordProtection: { password: "aPassword" } });

const response = await services.transport.identityRecoveryKits.doesIdentityRecoveryKitExist();
const response = await services.transport.identityRecoveryKits.checkForExistingIdentityRecoveryKit();
expect(response).toBeSuccessful();

expect(response.value.exists).toBe(true);
Expand Down

0 comments on commit 54901bd

Please sign in to comment.