From 157f85642d972c038dc832ce646b58bf556cd5a1 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Wed, 23 Oct 2024 22:07:17 +0530 Subject: [PATCH] feat: add exports Signed-off-by: Timo Glastra --- .../credential-request/credential-request.ts | 4 +- .../v-credential-request.ts | 1 - .../error/Oid4vcInvalidFetchResponseError.ts | 6 +- .../error/Oid4vcOauthErrorResponseError.ts | 5 +- packages/oid4vci/src/index.ts | 59 +++++++++++++++++++ .../credential-configurations.ts | 4 +- 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/packages/oid4vci/src/credential-request/credential-request.ts b/packages/oid4vci/src/credential-request/credential-request.ts index 3ea9719..a2d5410 100644 --- a/packages/oid4vci/src/credential-request/credential-request.ts +++ b/packages/oid4vci/src/credential-request/credential-request.ts @@ -10,7 +10,7 @@ import { Oid4vcOauthErrorResponseError } from '../error/Oid4vcOauthErrorResponse import { Oid4vcValidationError } from '../error/Oid4vcValidationError' import type { IssuerMetadataResult } from '../metadata/fetch-issuer-metadata' import { createValibotFetcher } from '../utils/valibot-fetcher' -import { type CredentialRequest, type CredentialRequestFormats, vCredentialRequest } from './v-credential-request' +import { type CredentialRequest, type CredentialRequestWithFormats, vCredentialRequest } from './v-credential-request' import type { CredentialRequestProof, CredentialRequestProofs } from './v-credential-request-common' import { vCredentialErrorResponse, vCredentialResponse } from './v-credential-response' @@ -46,7 +46,7 @@ export interface RetrieveCredentialsWithFormatOptions extends RetrieveCredential * The format specific payload. Needs to at least include the `format` and other params * are determined by the format itself */ - formatPayload: CredentialRequestFormats + formatPayload: CredentialRequestWithFormats proof?: CredentialRequestProof proofs?: CredentialRequestProofs diff --git a/packages/oid4vci/src/credential-request/v-credential-request.ts b/packages/oid4vci/src/credential-request/v-credential-request.ts index 5437be6..3197c02 100644 --- a/packages/oid4vci/src/credential-request/v-credential-request.ts +++ b/packages/oid4vci/src/credential-request/v-credential-request.ts @@ -29,7 +29,6 @@ const allCredentialRequestFormats = [ const allCredentialRequestFormatIdentifiers = allCredentialRequestFormats.map( (format) => format.entries.format.literal ) as string[] -export type CredentialRequestFormats = InferOutputUnion // Authorization details no format used const vAuthorizationDetailsCredentialRequest = v.looseObject({ diff --git a/packages/oid4vci/src/error/Oid4vcInvalidFetchResponseError.ts b/packages/oid4vci/src/error/Oid4vcInvalidFetchResponseError.ts index b3bf0a6..f70229d 100644 --- a/packages/oid4vci/src/error/Oid4vcInvalidFetchResponseError.ts +++ b/packages/oid4vci/src/error/Oid4vcInvalidFetchResponseError.ts @@ -1,10 +1,12 @@ +import type { FetchResponse } from '../globals' + export class Oid4vcInvalidFetchResponseError extends Error { - public readonly response: Response + public readonly response: FetchResponse public constructor( message: string, public readonly textResponse: string, - response: Response + response: FetchResponse ) { super(`${message}\n${textResponse}`) this.response = response.clone() diff --git a/packages/oid4vci/src/error/Oid4vcOauthErrorResponseError.ts b/packages/oid4vci/src/error/Oid4vcOauthErrorResponseError.ts index f8c51c6..52498c2 100644 --- a/packages/oid4vci/src/error/Oid4vcOauthErrorResponseError.ts +++ b/packages/oid4vci/src/error/Oid4vcOauthErrorResponseError.ts @@ -1,12 +1,13 @@ import type { Oauth2ErrorResponse } from '../common/v-oauth2-error' +import type { FetchResponse } from '../globals' export class Oid4vcOauthErrorResponseError extends Error { - public readonly response: Response + public readonly response: FetchResponse public constructor( message: string, public readonly errorResponse: Oauth2ErrorResponse, - response: Response + response: FetchResponse ) { super(`${message}\n${JSON.stringify(errorResponse, null, 2)}`) this.response = response.clone() diff --git a/packages/oid4vci/src/index.ts b/packages/oid4vci/src/index.ts index 0327c01..a998792 100644 --- a/packages/oid4vci/src/index.ts +++ b/packages/oid4vci/src/index.ts @@ -1 +1,60 @@ export { Oid4vciClient, Oid4vciClientOptions } from './client' + +export type { + CallbackContext, + GenerateRandomCallback, + HashCallback, + SignJwtCallback, + VerifyJwtCallback, +} from './callbacks' +export { HashAlgorithm } from './callbacks' + +export { Oid4vciDraftVersion } from './versions/draft-version' + +export type { + CredentialConfigurationSupported, + CredentialConfigurationSupportedWithFormat, + CredentialIssuerMetadata, + StrictCredentialConfigurationSupported, +} from './metadata/credential-issuer/v-credential-issuer-metadata' + +export { + extractScopesForCredentialConfigurationIds, + type ExtractScopesForCredentialConfigurationIdsOptions, +} from './metadata/credential-issuer/credential-configurations' + +export type { AuthorizationServerMetadata } from './metadata/authorization-server/v-authorization-server-metadata' + +export { + AccessTokenErrorResponse, + AccessTokenResponse, +} from './authorization/access-token/v-access-token' + +export { + type CredentialOfferObject, + authorizationCodeGrantIdentifier, + preAuthorizedCodeGrantIdentifier, +} from './credential-offer/v-credential-offer' + +export type { + CredentialRequestWithFormats, + CredentialRequest, + StrictCredentialRequest, +} from './credential-request/v-credential-request' +export type { CredentialErrorResponse, CredentialResponse } from './credential-request/v-credential-response' + +export { Oid4vcError, Oid4vcErrorOptions } from './error/Oid4vcError' +export { Oid4vcInvalidFetchResponseError } from './error/Oid4vcInvalidFetchResponseError' +export { Oid4vcJsonParseError } from './error/Oid4vcJsonParseError' +export { Oid4vcOauthErrorResponseError } from './error/Oid4vcOauthErrorResponseError' +export { Oid4vcValidationError } from './error/Oid4vcValidationError' + +export type { + JwtVcJsonFormatIdentifier, + JwtVcJsonLdFormatIdentifier, + LdpVcFormatIdentifier, + MsoMdocFormatIdentifier, + SdJwtVcFormatIdentifier, +} from './formats/credential' + +export { JwtProofTypeIdentifier } from './formats/proof-type/jwt/v-jwt-proof-type' diff --git a/packages/oid4vci/src/metadata/credential-issuer/credential-configurations.ts b/packages/oid4vci/src/metadata/credential-issuer/credential-configurations.ts index b65a598..4873a0c 100644 --- a/packages/oid4vci/src/metadata/credential-issuer/credential-configurations.ts +++ b/packages/oid4vci/src/metadata/credential-issuer/credential-configurations.ts @@ -1,7 +1,7 @@ import { Oid4vcError } from '../../error/Oid4vcError' import type { IssuerMetadataResult } from '../fetch-issuer-metadata' -interface ExtractScopesForCredentialConfigurationIds { +export interface ExtractScopesForCredentialConfigurationIdsOptions { /** * The credential configuration ids to extract the scope from */ @@ -21,7 +21,7 @@ interface ExtractScopesForCredentialConfigurationIds { issuerMetadata: IssuerMetadataResult } -export function extractScopesForCredentialConfigurationIds(options: ExtractScopesForCredentialConfigurationIds) { +export function extractScopesForCredentialConfigurationIds(options: ExtractScopesForCredentialConfigurationIdsOptions) { const scopes = new Set() for (const credentialConfigurationId of options.credentialConfigurationIds) {