From f59f415246a8d1a5e17c36ffefd77bc2fed93685 Mon Sep 17 00:00:00 2001 From: kkmanos Date: Wed, 8 Jan 2025 10:25:48 +0200 Subject: [PATCH] cleanup redundant classes --- src/lib/DIContainer.ts | 18 -------- .../AccessTokenManager/AccessTokenManager.tsx | 45 ------------------- .../CredentialEndpoint/CredentialEndpoint.tsx | 20 --------- 3 files changed, 83 deletions(-) delete mode 100644 src/lib/DIContainer.ts delete mode 100644 src/lib/services/OpenID4VCI/AccessTokenManager/AccessTokenManager.tsx delete mode 100644 src/lib/services/OpenID4VCI/CredentialEndpoint/CredentialEndpoint.tsx diff --git a/src/lib/DIContainer.ts b/src/lib/DIContainer.ts deleted file mode 100644 index 6f9298c7..00000000 --- a/src/lib/DIContainer.ts +++ /dev/null @@ -1,18 +0,0 @@ -type Constructor = new (...args: any[]) => T; - -export class DIContainer { - private services = new Map(); - - register(name: string, service: Constructor, ...args: any[]): void { - this.services.set(name, new service(...args)); - } - - resolve(name: string): T { - const service = this.services.get(name); - if (!service) { - throw new Error(`Service not found: ${name}`); - } - return service; - } -} - diff --git a/src/lib/services/OpenID4VCI/AccessTokenManager/AccessTokenManager.tsx b/src/lib/services/OpenID4VCI/AccessTokenManager/AccessTokenManager.tsx deleted file mode 100644 index 4617f3a8..00000000 --- a/src/lib/services/OpenID4VCI/AccessTokenManager/AccessTokenManager.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { useContext } from "react" -import SessionContext from "../../../../context/SessionContext" - - -export type AccessToken = { - access_token: string; - expires_in: number; - c_nonce: string; - c_nonce_expires_in: number; - refresh_token?: string; -} - -export enum GetAccessTokenErr { - NO_TOK_AVAILABLE -} - -export function useAccessTokenManager() { - - const { keystore } = useContext(SessionContext); - - - async function getAccessToken(credentialIssuerIdentifier: string): Promise<{ at: AccessToken } | { err: GetAccessTokenErr }> { - // get active access token for keystore.getUserHandle and this credentialIssuerIdentifier by searching the openid4vci client state repo - // if current access token is valid, return it from the flow state - // else if refresh token is available - // then getAccessTokenWithRefreshTokenGrant() and return the token - // else if authorizatio code currently available then execute getAccessTokenWithAuthorizationCodeGrant() and return it - // else return GetAccessTokenErr - } - - function getAccessTokenUsingAuthorizationCodeGrant(credentialIssuerIdentifier: string) { - // request token using authorization code grant - // the request will be constructed using the current flowstate - } - - - function getAccessTokenUsingRefreshTokenGrant(credentialIssuerIdentifier: string) { - // request token using refrhes token grant - // the request will be constructed using the current flowstate - } - - return { - getAccessToken - } -} \ No newline at end of file diff --git a/src/lib/services/OpenID4VCI/CredentialEndpoint/CredentialEndpoint.tsx b/src/lib/services/OpenID4VCI/CredentialEndpoint/CredentialEndpoint.tsx deleted file mode 100644 index d578a75b..00000000 --- a/src/lib/services/OpenID4VCI/CredentialEndpoint/CredentialEndpoint.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { useContext } from "react"; -import { AccessToken } from "../AccessTokenManager/AccessTokenManager"; -import SessionContext from "../../../../context/SessionContext"; -import { useHttpProxy } from "../../HttpProxy/HttpProxy"; - - -export function useCredentialEndpoint() { - - const { keystore } = useContext(SessionContext); - const httpProxy = useHttpProxy(); - - async function sendCredentialRequest(at: AccessToken) { - // manage cached proofs etc.... - // if credential request fails due to dpop nonce issue, then request again - } - - return { - sendCredentialRequest - } -} \ No newline at end of file