Skip to content

Commit

Permalink
feat: add exports
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Oct 23, 2024
1 parent f861d41 commit 157f856
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/oid4vci/src/credential-request/credential-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const allCredentialRequestFormats = [
const allCredentialRequestFormatIdentifiers = allCredentialRequestFormats.map(
(format) => format.entries.format.literal
) as string[]
export type CredentialRequestFormats = InferOutputUnion<typeof allCredentialRequestFormats>

// Authorization details no format used
const vAuthorizationDetailsCredentialRequest = v.looseObject({
Expand Down
6 changes: 4 additions & 2 deletions packages/oid4vci/src/error/Oid4vcInvalidFetchResponseError.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
5 changes: 3 additions & 2 deletions packages/oid4vci/src/error/Oid4vcOauthErrorResponseError.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
59 changes: 59 additions & 0 deletions packages/oid4vci/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -21,7 +21,7 @@ interface ExtractScopesForCredentialConfigurationIds {
issuerMetadata: IssuerMetadataResult
}

export function extractScopesForCredentialConfigurationIds(options: ExtractScopesForCredentialConfigurationIds) {
export function extractScopesForCredentialConfigurationIds(options: ExtractScopesForCredentialConfigurationIdsOptions) {
const scopes = new Set<string>()

for (const credentialConfigurationId of options.credentialConfigurationIds) {
Expand Down

0 comments on commit 157f856

Please sign in to comment.