diff --git a/package.json b/package.json index c338876..7caae6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tanglelabs/oid4vc", - "version": "0.2.1-alpha.11", + "version": "0.2.1-alpha.12", "main": "dist/index.js", "license": "MIT", "type": "module", diff --git a/src/oid4vci/Issuer/index.types.ts b/src/oid4vci/Issuer/index.types.ts index afdf6c5..6fe7bb3 100644 --- a/src/oid4vci/Issuer/index.types.ts +++ b/src/oid4vci/Issuer/index.types.ts @@ -1,64 +1,65 @@ -import { Resolvable } from "did-resolver"; -import { KeyPairRequirements } from "../../common/index.types"; +import { Resolvable } from 'did-resolver'; +import { KeyPairRequirements } from '../../common/index.types'; -type CryptographicSuites = "EdDSA" | "ES256"; -type ProofTypes = "jwt"; +type CryptographicSuites = 'EdDSA' | 'ES256'; +type ProofTypes = 'jwt'; +export type CredentialFormat = 'vc+sd-jwt' | 'dc+sd-jwt' | 'jwt_vc_json'; export type SupportedCredentials = { - name: string; - type: string[]; - display?: { - name?: string; - locale?: string; - logo?: { - uri: string; - alt_text?: string; - }; - }[]; - raw?: Record; - format: "vc+sd-jwt" | "dc+sd-jwt" | "jwt_vc_json"; + name: string; + type: string[]; + display?: { + name?: string; + locale?: string; + logo?: { + uri: string; + alt_text?: string; + }; + }[]; + raw?: Record; + format: CredentialFormat; }; export type VcIssuerOptions = { - credentialEndpoint: string; - tokenEndpoint: string; - batchCredentialEndpoint: string; - credentialIssuer: string; - cryptographicBindingMethodsSupported: string[]; - credentialSigningAlgValuesSupported: CryptographicSuites[]; - proofTypesSupported: ProofTypes[]; - store: IIssuerStore; - logoUri?: string; - clientName?: string; - supportedCredentials?: SupportedCredentials[]; - resolver: Resolvable; + credentialEndpoint: string; + tokenEndpoint: string; + batchCredentialEndpoint: string; + credentialIssuer: string; + cryptographicBindingMethodsSupported: string[]; + credentialSigningAlgValuesSupported: CryptographicSuites[]; + proofTypesSupported: ProofTypes[]; + store: IIssuerStore; + logoUri?: string; + clientName?: string; + supportedCredentials?: SupportedCredentials[]; + resolver: Resolvable; } & KeyPairRequirements; export type IssuerStoreData = { id: string; pin: number }; type CreateCredentialOfferByValue = { - requestBy: "value"; - credentials: string[]; - pinRequired?: boolean; - expiresIn?: number; + requestBy: 'value'; + credentials: string[]; + pinRequired?: boolean; + expiresIn?: number; }; type CreateCredentialOfferByReference = { - requestBy: "reference"; - credentialOfferUri: string; - credentials: string[]; - pinRequired?: boolean; - expiresIn?: number; + requestBy: 'reference'; + credentialOfferUri: string; + credentials: string[]; + pinRequired?: boolean; + expiresIn?: number; }; export type CreateCredentialOfferOptions = - | CreateCredentialOfferByReference - | CreateCredentialOfferByValue; + | CreateCredentialOfferByReference + | CreateCredentialOfferByValue; export interface IIssuerStore { - create: (payload: T) => Promise | T; - getAll: () => Promise | T[]; - getById: (id: string) => Promise | T; - updateById: (id: string, payload: Partial) => Promise | T; - deleteById: (id: string) => Promise; + create: (payload: T) => Promise | T; + getAll: () => Promise | T[]; + getById: (id: string) => Promise | T; + updateById: (id: string, payload: Partial) => Promise | T; + deleteById: (id: string) => Promise; } diff --git a/src/oid4vci/Issuer/issuer.ts b/src/oid4vci/Issuer/issuer.ts index 3aeb81c..73abb90 100644 --- a/src/oid4vci/Issuer/issuer.ts +++ b/src/oid4vci/Issuer/issuer.ts @@ -9,6 +9,7 @@ import { IssuerStoreData, SupportedCredentials, VcIssuerOptions, + CredentialFormat, } from './index.types'; import { generatePin } from '../../utils/pin'; import { TokenRequest } from '../Holder/index.types'; @@ -230,15 +231,17 @@ export class VcIssuer { async createSendCredentialsResponse({ credentials, + format, }: { credentials: string[]; + format: CredentialFormat; }) { let response; if (credentials.length > 1) { // @ts-ignore response = { credential_responses: [] }; response.credential_responses = credentials.map((credential) => ({ - format: 'jwt_vc_json', + format, credential, })); } else { diff --git a/src/tests/mocks/openid.ts b/src/tests/mocks/openid.ts index 217152e..52f0169 100644 --- a/src/tests/mocks/openid.ts +++ b/src/tests/mocks/openid.ts @@ -14,11 +14,6 @@ import { testingKeys } from './keys.mock'; import path from 'path'; import { fileURLToPath } from 'url'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -const file = path.resolve(__dirname, './store.test-mock'); - class Store { create(payload: { id: string; pin: number }) { return { id: payload.id, pin: null } as { diff --git a/src/tests/mocks/server.ts b/src/tests/mocks/server.ts index 5dbf3ee..3bb430b 100644 --- a/src/tests/mocks/server.ts +++ b/src/tests/mocks/server.ts @@ -40,6 +40,7 @@ export function startServer(port = 5999) { }); const response = await issuer.createSendCredentialsResponse({ credentials: credentials, + format: 'jwt_vc_json', }); res.json(response); }); @@ -55,6 +56,7 @@ export function startServer(port = 5999) { }); const response = await issuer.createSendCredentialsResponse({ credentials: [...credentials, ...credentials], + format: 'jwt_vc_json', }); res.json(response); });