Authoritative interface types shared by Lemma SDK and Workers. This package contains TypeScript type definitions and OpenAPI specifications for the Lemma oracle system.
# Using npm
npm install @lemmaoracle/spec
# Using pnpm
pnpm add @lemmaoracle/spec
# Using yarn
yarn add @lemmaoracle/specNote: This package is a required dependency for
@lemmaoracle/sdk.
@lemmaoracle/spec provides:
- TypeScript type definitions for all Lemma API interfaces
- OpenAPI specification (v2) for the Lemma REST API
- Shared interfaces between SDK and backend services
- Immutable data types with strict functional programming constraints
export type LemmaClientConfig = Readonly<{
apiBase: string;
apiKey?: string;
}>;
export type LemmaClient = LemmaClientConfig &
Readonly<{
readonly fetcher?: typeof fetch;
}>;export type SchemaMeta = Readonly<{
id: string;
description?: string;
normalize: NormalizeArtifact;
[k: string]: unknown;
}>;
export type NormalizeArtifact = Readonly<{
artifact: {
readonly type: "ipfs" | "https";
readonly wasm: string;
};
hash: string;
abi?: {
readonly raw: Record<string, string>;
readonly norm: Record<string, string>;
};
}>;export type CircuitMeta = Readonly<{
circuitId: string;
schema: string;
description?: string;
inputs?: ReadonlyArray<string>;
verifier?: Readonly<{
type: "onchain" | "offchain";
address?: string;
chainId?: number;
[k: string]: unknown;
}>;
artifact?: Readonly<{ location: CircuitArtifactLocation }>;
[k: string]: unknown;
}>;export type RegisterDocumentRequest = Readonly<{
schema: string;
docHash: string;
cid: string;
issuerId: string;
subjectId: string;
commitments: DocumentCommitments;
revocation: Revocation;
signature?: IssuerSignature;
hooks?: ReadonlyArray<OnchainHook>;
}>;
export type RegisterDocumentResponse = Readonly<{
status: "registered";
docHash: string;
[k: string]: unknown;
}>;export type SubmitProofRequest = Readonly<{
docHash: string;
circuitId: string;
proof: string;
inputs: ReadonlyArray<string>;
disclosure?: SelectiveDisclosure;
onchain?: boolean;
}>;
export type SubmitProofResponse = Readonly<{
status: "received" | "verified" | "onchain-verified" | "rejected";
verificationId: string;
[k: string]: unknown;
}>;export type VerifiedAttributesQueryRequest = Readonly<{
query: string;
mode: "natural" | "structured";
attributes?: ReadonlyArray<Readonly<{ name: string; value: unknown }>>;
proof?: Readonly<{ required: boolean; type?: "zk-snark" | "opaque" }>;
targets?: Readonly<{ schemas?: ReadonlyArray<string> } & Record<string, unknown>>;
}>;
export type VerifiedAttributesQueryResponse = Readonly<{
results: ReadonlyArray<VerifiedAttributesQueryResponseItem>;
}>;export type CommitmentScheme = "poseidon" | "poseidon2" | "rescue-prime" | "sha256-placeholder";
export type DocumentCommitments = Readonly<{
scheme: CommitmentScheme;
root: string;
leaves: ReadonlyArray<string>;
randomness: string; // bytes32 hex - blinding factor for hiding property
}>;export type SelectiveDisclosure = Readonly<{
format: "bbs+" | "opaque";
attributes: Readonly<Record<string, unknown>>;
proof: string;
}>;# Clone the repository
git clone <repository-url>
cd lemma
# Install dependencies
pnpm install
# Build the spec package
cd packages/spec
pnpm buildThe package includes an OpenAPI v2 specification at openapi.lemma.v2.json. This file is automatically included in the npm package and can be used for:
- API documentation generation
- Client SDK generation in other languages
- API validation and testing
All types use Readonly<> and ReadonlyArray<> to enforce immutability, following Lemma's functional programming guidelines.
- npm account with access to
@lemmaoracleorganization - Authentication configured (
npm login)
# Build the package
pnpm build
# Publish to npm
npm publish --access publicThis package uses semantic versioning. When making breaking changes to types, increment the major version. The SDK depends on specific versions of this package, so coordinate updates accordingly.
MIT