Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
89 changes: 45 additions & 44 deletions src/oid4vci/Issuer/index.types.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>;
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<string, any>;
format: CredentialFormat;
};

export type VcIssuerOptions = {
credentialEndpoint: string;
tokenEndpoint: string;
batchCredentialEndpoint: string;
credentialIssuer: string;
cryptographicBindingMethodsSupported: string[];
credentialSigningAlgValuesSupported: CryptographicSuites[];
proofTypesSupported: ProofTypes[];
store: IIssuerStore<IssuerStoreData>;
logoUri?: string;
clientName?: string;
supportedCredentials?: SupportedCredentials[];
resolver: Resolvable;
credentialEndpoint: string;
tokenEndpoint: string;
batchCredentialEndpoint: string;
credentialIssuer: string;
cryptographicBindingMethodsSupported: string[];
credentialSigningAlgValuesSupported: CryptographicSuites[];
proofTypesSupported: ProofTypes[];
store: IIssuerStore<IssuerStoreData>;
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<T> {
create: (payload: T) => Promise<T> | T;
getAll: () => Promise<T[]> | T[];
getById: (id: string) => Promise<T> | T;
updateById: (id: string, payload: Partial<T>) => Promise<T> | T;
deleteById: (id: string) => Promise<T>;
create: (payload: T) => Promise<T> | T;
getAll: () => Promise<T[]> | T[];
getById: (id: string) => Promise<T> | T;
updateById: (id: string, payload: Partial<T>) => Promise<T> | T;
deleteById: (id: string) => Promise<T>;
}
5 changes: 4 additions & 1 deletion src/oid4vci/Issuer/issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IssuerStoreData,
SupportedCredentials,
VcIssuerOptions,
CredentialFormat,
} from './index.types';
import { generatePin } from '../../utils/pin';
import { TokenRequest } from '../Holder/index.types';
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions src/tests/mocks/openid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/tests/mocks/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function startServer(port = 5999) {
});
const response = await issuer.createSendCredentialsResponse({
credentials: credentials,
format: 'jwt_vc_json',
});
res.json(response);
});
Expand All @@ -55,6 +56,7 @@ export function startServer(port = 5999) {
});
const response = await issuer.createSendCredentialsResponse({
credentials: [...credentials, ...credentials],
format: 'jwt_vc_json',
});
res.json(response);
});
Expand Down
Loading