@lemmaoracle/spec 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # @lemmaoracle/spec
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@lemmaoracle/spec)](https://www.npmjs.com/package/@lemmaoracle/spec)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.5-blue)](https://www.typescriptlang.org/)
5
+
6
+ Authoritative interface types shared by Lemma SDK and Workers. This package contains TypeScript type definitions and OpenAPI specifications for the Lemma oracle system.
7
+
8
+ ## 📦 Installation
9
+
10
+ ```bash
11
+ # Using npm
12
+ npm install @lemmaoracle/spec
13
+
14
+ # Using pnpm
15
+ pnpm add @lemmaoracle/spec
16
+
17
+ # Using yarn
18
+ yarn add @lemmaoracle/spec
19
+ ```
20
+
21
+ > **Note**: This package is a required dependency for `@lemmaoracle/sdk`.
22
+
23
+ ## 🎯 Overview
24
+
25
+ `@lemmaoracle/spec` provides:
26
+
27
+ - **TypeScript type definitions** for all Lemma API interfaces
28
+ - **OpenAPI specification** (v2) for the Lemma REST API
29
+ - **Shared interfaces** between SDK and backend services
30
+ - **Immutable data types** with strict functional programming constraints
31
+
32
+ ## 📖 API Reference
33
+
34
+ ### Core Types
35
+
36
+ #### Lemma Client
37
+
38
+ ```typescript
39
+ export type LemmaClientConfig = Readonly<{
40
+ apiBase: string;
41
+ apiKey?: string;
42
+ }>;
43
+
44
+ export type LemmaClient = LemmaClientConfig &
45
+ Readonly<{
46
+ readonly fetcher?: typeof fetch;
47
+ }>;
48
+ ```
49
+
50
+ #### Schema Metadata
51
+
52
+ ```typescript
53
+ export type SchemaMeta = Readonly<{
54
+ id: string;
55
+ description?: string;
56
+ normalize: NormalizeArtifact;
57
+ [k: string]: unknown;
58
+ }>;
59
+
60
+ export type NormalizeArtifact = Readonly<{
61
+ artifact: {
62
+ readonly type: "ipfs" | "https";
63
+ readonly wasm: string;
64
+ };
65
+ hash: string;
66
+ abi?: {
67
+ readonly raw: Record<string, string>;
68
+ readonly norm: Record<string, string>;
69
+ };
70
+ }>;
71
+ ```
72
+
73
+ #### Circuit Metadata
74
+
75
+ ```typescript
76
+ export type CircuitMeta = Readonly<{
77
+ circuitId: string;
78
+ schema: string;
79
+ description?: string;
80
+ inputs?: ReadonlyArray<string>;
81
+ verifier?: Readonly<{
82
+ type: "onchain" | "offchain";
83
+ address?: string;
84
+ chainId?: number;
85
+ [k: string]: unknown;
86
+ }>;
87
+ artifact?: Readonly<{ location: CircuitArtifactLocation }>;
88
+ [k: string]: unknown;
89
+ }>;
90
+ ```
91
+
92
+ #### Document Registration
93
+
94
+ ```typescript
95
+ export type RegisterDocumentRequest = Readonly<{
96
+ schema: string;
97
+ docHash: string;
98
+ cid: string;
99
+ issuerId: string;
100
+ subjectId: string;
101
+ commitments: DocumentCommitments;
102
+ revocation: Revocation;
103
+ signature?: IssuerSignature;
104
+ hooks?: ReadonlyArray<OnchainHook>;
105
+ }>;
106
+
107
+ export type RegisterDocumentResponse = Readonly<{
108
+ status: "registered";
109
+ docHash: string;
110
+ [k: string]: unknown;
111
+ }>;
112
+ ```
113
+
114
+ #### Proof Submission
115
+
116
+ ```typescript
117
+ export type SubmitProofRequest = Readonly<{
118
+ docHash: string;
119
+ circuitId: string;
120
+ proof: string;
121
+ inputs: ReadonlyArray<string>;
122
+ disclosure?: SelectiveDisclosure;
123
+ onchain?: boolean;
124
+ }>;
125
+
126
+ export type SubmitProofResponse = Readonly<{
127
+ status: "received" | "verified" | "onchain-verified" | "rejected";
128
+ verificationId: string;
129
+ [k: string]: unknown;
130
+ }>;
131
+ ```
132
+
133
+ #### Verified Attributes Query
134
+
135
+ ```typescript
136
+ export type VerifiedAttributesQueryRequest = Readonly<{
137
+ query: string;
138
+ mode: "natural" | "structured";
139
+ attributes?: ReadonlyArray<Readonly<{ name: string; value: unknown }>>;
140
+ proof?: Readonly<{ required: boolean; type?: "zk-snark" | "opaque" }>;
141
+ targets?: Readonly<{ schemas?: ReadonlyArray<string> } & Record<string, unknown>>;
142
+ }>;
143
+
144
+ export type VerifiedAttributesQueryResponse = Readonly<{
145
+ results: ReadonlyArray<VerifiedAttributesQueryResponseItem>;
146
+ }>;
147
+ ```
148
+
149
+ ### Commitment Schemes
150
+
151
+ ```typescript
152
+ export type CommitmentScheme = "poseidon" | "poseidon2" | "rescue-prime" | "sha256-placeholder";
153
+
154
+ export type DocumentCommitments = Readonly<{
155
+ scheme: CommitmentScheme;
156
+ root: string;
157
+ leaves: ReadonlyArray<string>;
158
+ randomness: string; // bytes32 hex - blinding factor for hiding property
159
+ }>;
160
+ ```
161
+
162
+ ### Selective Disclosure
163
+
164
+ ```typescript
165
+ export type SelectiveDisclosure = Readonly<{
166
+ format: "bbs+" | "opaque";
167
+ attributes: Readonly<Record<string, unknown>>;
168
+ proof: string;
169
+ }>;
170
+ ```
171
+
172
+ ## 🔧 Development
173
+
174
+ ### Building from Source
175
+
176
+ ```bash
177
+ # Clone the repository
178
+ git clone <repository-url>
179
+ cd lemma
180
+
181
+ # Install dependencies
182
+ pnpm install
183
+
184
+ # Build the spec package
185
+ cd packages/spec
186
+ pnpm build
187
+ ```
188
+
189
+ ### OpenAPI Specification
190
+
191
+ The 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:
192
+
193
+ - API documentation generation
194
+ - Client SDK generation in other languages
195
+ - API validation and testing
196
+
197
+ ### TypeScript Strict Mode
198
+
199
+ All types use `Readonly<>` and `ReadonlyArray<>` to enforce immutability, following Lemma's functional programming guidelines.
200
+
201
+ ## 📦 Publishing
202
+
203
+ ### Prerequisites
204
+ 1. npm account with access to `@lemmaoracle` organization
205
+ 2. Authentication configured (`npm login`)
206
+
207
+ ### Publishing Process
208
+
209
+ ```bash
210
+ # Build the package
211
+ pnpm build
212
+
213
+ # Publish to npm
214
+ npm publish --access public
215
+ ```
216
+
217
+ ### Version Management
218
+
219
+ This 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.
220
+
221
+ ## 📄 License
222
+
223
+ MIT
@@ -0,0 +1,158 @@
1
+ /**
2
+ * @lemmaoracle/spec — Authoritative interface types shared by SDK and Workers.
3
+ * MUST remain identical (or semver-compatible) across both repositories.
4
+ *
5
+ * Whitepaper reference: §2, §3, §4.
6
+ */
7
+ export type LemmaClientConfig = Readonly<{
8
+ apiBase: string;
9
+ apiKey?: string;
10
+ }>;
11
+ export type LemmaClient = LemmaClientConfig & Readonly<{
12
+ readonly fetcher?: typeof fetch;
13
+ }>;
14
+ export type SchemaMeta = Readonly<{
15
+ id: string;
16
+ description?: string;
17
+ normalize: NormalizeArtifact;
18
+ [k: string]: unknown;
19
+ }>;
20
+ export type NormalizeArtifact = Readonly<{
21
+ artifact: {
22
+ readonly type: "ipfs" | "https";
23
+ readonly wasm: string;
24
+ };
25
+ hash: string;
26
+ abi?: {
27
+ readonly raw: Record<string, string>;
28
+ readonly norm: Record<string, string>;
29
+ };
30
+ }>;
31
+ export type CircuitArtifactLocation = Readonly<{
32
+ type: "ipfs" | "https";
33
+ wasm: string;
34
+ zkey: string;
35
+ }>;
36
+ export type CircuitMeta = Readonly<{
37
+ circuitId: string;
38
+ schema: string;
39
+ description?: string;
40
+ inputs?: ReadonlyArray<string>;
41
+ verifier?: Readonly<{
42
+ type: "onchain" | "offchain";
43
+ address?: string;
44
+ chainId?: number;
45
+ [k: string]: unknown;
46
+ }>;
47
+ artifact?: Readonly<{
48
+ location: CircuitArtifactLocation;
49
+ }>;
50
+ [k: string]: unknown;
51
+ }>;
52
+ export type GeneratorMeta = Readonly<{
53
+ generatorId: string;
54
+ schema: string;
55
+ description?: string;
56
+ language?: string;
57
+ source?: Readonly<{
58
+ type: "url";
59
+ uri: string;
60
+ }>;
61
+ inputsSpec?: Readonly<Record<string, unknown>>;
62
+ outputsSpec?: Readonly<Record<string, unknown>>;
63
+ [k: string]: unknown;
64
+ }>;
65
+ export type CommitmentScheme = "poseidon" | "poseidon2" | "rescue-prime" | "sha256-placeholder";
66
+ export type DocumentCommitments = Readonly<{
67
+ scheme: CommitmentScheme;
68
+ root: string;
69
+ leaves: ReadonlyArray<string>;
70
+ randomness: string;
71
+ }>;
72
+ export type Revocation = Readonly<{
73
+ scheme?: string;
74
+ root: string;
75
+ [k: string]: unknown;
76
+ }>;
77
+ export type IssuerSignature = Readonly<{
78
+ format: "bbs+" | "opaque";
79
+ payload: string;
80
+ issuerId: string;
81
+ }>;
82
+ export type OnchainHook = Readonly<{
83
+ chainId: number;
84
+ address: string;
85
+ method: string;
86
+ mode?: "after-registry";
87
+ payload?: "registry-public-inputs";
88
+ [k: string]: unknown;
89
+ }>;
90
+ export type RegisterDocumentRequest = Readonly<{
91
+ schema: string;
92
+ docHash: string;
93
+ cid: string;
94
+ issuerId: string;
95
+ subjectId: string;
96
+ attributes?: Readonly<Record<string, unknown>>;
97
+ commitments: DocumentCommitments;
98
+ revocation: Revocation;
99
+ signature?: IssuerSignature;
100
+ hooks?: ReadonlyArray<OnchainHook>;
101
+ }>;
102
+ export type RegisterDocumentResponse = Readonly<{
103
+ status: "registered";
104
+ docHash: string;
105
+ [k: string]: unknown;
106
+ }>;
107
+ export type SelectiveDisclosure = Readonly<{
108
+ format: "bbs+" | "opaque";
109
+ attributes: Readonly<Record<string, unknown>>;
110
+ proof: string;
111
+ }>;
112
+ export type SubmitProofRequest = Readonly<{
113
+ docHash: string;
114
+ circuitId: string;
115
+ proof: string;
116
+ inputs: ReadonlyArray<string>;
117
+ disclosure?: SelectiveDisclosure;
118
+ onchain?: boolean;
119
+ }>;
120
+ export type SubmitProofResponse = Readonly<{
121
+ status: "received" | "verified" | "onchain-verified" | "rejected";
122
+ verificationId: string;
123
+ [k: string]: unknown;
124
+ }>;
125
+ export type VerifiedAttributesQueryRequest = Readonly<{
126
+ query: string;
127
+ mode: "natural" | "structured";
128
+ attributes?: ReadonlyArray<Readonly<{
129
+ name: string;
130
+ value: unknown;
131
+ }>>;
132
+ proof?: Readonly<{
133
+ required: boolean;
134
+ type?: "zk-snark" | "opaque";
135
+ }>;
136
+ targets?: Readonly<{
137
+ schemas?: ReadonlyArray<string>;
138
+ } & Record<string, unknown>>;
139
+ }>;
140
+ export type VerifiedAttributesQueryResponseItem = Readonly<{
141
+ docHash: string;
142
+ schema: string;
143
+ issuerId: string;
144
+ subjectId: string;
145
+ attributes: Readonly<Record<string, unknown>>;
146
+ proof?: Readonly<{
147
+ status?: string;
148
+ circuitId?: string;
149
+ } & Record<string, unknown>>;
150
+ disclosure?: SelectiveDisclosure;
151
+ }>;
152
+ export type VerifiedAttributesQueryResponse = Readonly<{
153
+ results: ReadonlyArray<VerifiedAttributesQueryResponseItem>;
154
+ }>;
155
+ export type ErrorResponse = Readonly<{
156
+ error: string;
157
+ }>;
158
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,iBAAiB,GACzC,QAAQ,CAAC;IACP,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACjC,CAAC,CAAC;AAIL,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,QAAQ,EAAE;QACR,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAA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,CAAC;AAIH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @lemmaoracle/spec — Authoritative interface types shared by SDK and Workers.
3
+ * MUST remain identical (or semver-compatible) across both repositories.
4
+ *
5
+ * Whitepaper reference: §2, §3, §4.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,502 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "Lemma v2 API",
5
+ "version": "0.1.0",
6
+ "description": "REST surface derived from the Lemma v2 whitepaper SDK interface (§3, §4)."
7
+ },
8
+ "servers": [{ "url": "http://localhost:8787" }],
9
+ "components": {
10
+ "securitySchemes": {
11
+ "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "x-api-key" }
12
+ },
13
+ "schemas": {
14
+ "ErrorResponse": {
15
+ "type": "object",
16
+ "properties": { "error": { "type": "string" } },
17
+ "required": ["error"],
18
+ "additionalProperties": false
19
+ },
20
+ "SchemaMeta": {
21
+ "type": "object",
22
+ "properties": {
23
+ "id": { "type": "string" },
24
+ "description": { "type": "string" }
25
+ },
26
+ "required": ["id"],
27
+ "additionalProperties": true
28
+ },
29
+ "CircuitArtifactLocation": {
30
+ "type": "object",
31
+ "properties": {
32
+ "type": { "type": "string", "enum": ["ipfs", "https"] },
33
+ "wasm": { "type": "string" },
34
+ "zkey": { "type": "string" }
35
+ },
36
+ "required": ["type", "wasm", "zkey"],
37
+ "additionalProperties": false
38
+ },
39
+ "CircuitMeta": {
40
+ "type": "object",
41
+ "properties": {
42
+ "circuitId": { "type": "string" },
43
+ "schema": { "type": "string" },
44
+ "description": { "type": "string" },
45
+ "inputs": { "type": "array", "items": { "type": "string" } },
46
+ "verifier": {
47
+ "type": "object",
48
+ "properties": {
49
+ "type": { "type": "string", "enum": ["onchain", "offchain"] },
50
+ "address": { "type": "string" },
51
+ "chainId": { "type": "integer" }
52
+ },
53
+ "required": ["type"],
54
+ "additionalProperties": true
55
+ },
56
+ "artifact": {
57
+ "type": "object",
58
+ "properties": {
59
+ "location": { "$ref": "#/components/schemas/CircuitArtifactLocation" }
60
+ },
61
+ "required": ["location"],
62
+ "additionalProperties": false
63
+ }
64
+ },
65
+ "required": ["circuitId", "schema"],
66
+ "additionalProperties": true
67
+ },
68
+ "GeneratorMeta": {
69
+ "type": "object",
70
+ "properties": {
71
+ "generatorId": { "type": "string" },
72
+ "schema": { "type": "string" },
73
+ "description": { "type": "string" },
74
+ "language": { "type": "string" },
75
+ "source": {
76
+ "type": "object",
77
+ "properties": {
78
+ "type": { "type": "string", "enum": ["url"] },
79
+ "uri": { "type": "string" }
80
+ },
81
+ "required": ["type", "uri"],
82
+ "additionalProperties": false
83
+ },
84
+ "inputsSpec": { "type": "object", "additionalProperties": true },
85
+ "outputsSpec": { "type": "object", "additionalProperties": true }
86
+ },
87
+ "required": ["generatorId", "schema"],
88
+ "additionalProperties": true
89
+ },
90
+ "DocumentCommitments": {
91
+ "type": "object",
92
+ "properties": {
93
+ "scheme": {
94
+ "type": "string",
95
+ "enum": ["poseidon", "poseidon2", "rescue-prime", "sha256-placeholder"]
96
+ },
97
+ "root": { "type": "string" },
98
+ "leaves": {
99
+ "type": "array",
100
+ "items": { "type": "string" }
101
+ },
102
+ "randomness": { "type": "string" }
103
+ },
104
+ "required": ["scheme", "root", "leaves", "randomness"],
105
+ "additionalProperties": false
106
+ },
107
+ "Revocation": {
108
+ "type": "object",
109
+ "properties": {
110
+ "scheme": { "type": "string" },
111
+ "root": { "type": "string" }
112
+ },
113
+ "required": ["root"],
114
+ "additionalProperties": true
115
+ },
116
+ "IssuerSignature": {
117
+ "type": "object",
118
+ "properties": {
119
+ "format": { "type": "string", "enum": ["bbs+", "opaque"] },
120
+ "payload": { "type": "string" },
121
+ "issuerId": { "type": "string" }
122
+ },
123
+ "required": ["format", "payload", "issuerId"],
124
+ "additionalProperties": false
125
+ },
126
+ "OnchainHook": {
127
+ "type": "object",
128
+ "properties": {
129
+ "chainId": { "type": "integer" },
130
+ "address": { "type": "string" },
131
+ "method": { "type": "string" },
132
+ "mode": { "type": "string", "enum": ["after-registry"] },
133
+ "payload": { "type": "string", "enum": ["registry-public-inputs"] }
134
+ },
135
+ "required": ["chainId", "address", "method"],
136
+ "additionalProperties": true
137
+ },
138
+ "RegisterDocumentRequest": {
139
+ "type": "object",
140
+ "properties": {
141
+ "schema": { "type": "string" },
142
+ "docHash": { "type": "string" },
143
+ "cid": { "type": "string" },
144
+ "issuerId": { "type": "string" },
145
+ "subjectId": { "type": "string" },
146
+ "commitments": { "$ref": "#/components/schemas/DocumentCommitments" },
147
+ "revocation": { "$ref": "#/components/schemas/Revocation" },
148
+ "signature": { "$ref": "#/components/schemas/IssuerSignature" },
149
+ "hooks": {
150
+ "type": "array",
151
+ "items": { "$ref": "#/components/schemas/OnchainHook" }
152
+ }
153
+ },
154
+ "required": [
155
+ "schema",
156
+ "docHash",
157
+ "cid",
158
+ "issuerId",
159
+ "subjectId",
160
+ "commitments",
161
+ "revocation"
162
+ ],
163
+ "additionalProperties": false
164
+ },
165
+ "RegisterDocumentResponse": {
166
+ "type": "object",
167
+ "properties": {
168
+ "status": { "type": "string", "enum": ["registered"] },
169
+ "docHash": { "type": "string" }
170
+ },
171
+ "required": ["status", "docHash"],
172
+ "additionalProperties": true
173
+ },
174
+ "SelectiveDisclosure": {
175
+ "type": "object",
176
+ "properties": {
177
+ "format": { "type": "string", "enum": ["bbs+", "opaque"] },
178
+ "attributes": { "type": "object", "additionalProperties": true },
179
+ "proof": { "type": "string" }
180
+ },
181
+ "required": ["format", "attributes", "proof"],
182
+ "additionalProperties": false
183
+ },
184
+ "SubmitProofRequest": {
185
+ "type": "object",
186
+ "properties": {
187
+ "docHash": { "type": "string" },
188
+ "circuitId": { "type": "string" },
189
+ "proof": { "type": "string" },
190
+ "inputs": { "type": "array", "items": { "type": "string" } },
191
+ "disclosure": { "$ref": "#/components/schemas/SelectiveDisclosure" },
192
+ "onchain": { "type": "boolean" }
193
+ },
194
+ "required": ["docHash", "circuitId", "proof", "inputs"],
195
+ "additionalProperties": false
196
+ },
197
+ "SubmitProofResponse": {
198
+ "type": "object",
199
+ "properties": {
200
+ "status": {
201
+ "type": "string",
202
+ "enum": ["received", "verified", "onchain-verified", "rejected"]
203
+ },
204
+ "verificationId": { "type": "string" }
205
+ },
206
+ "required": ["status", "verificationId"],
207
+ "additionalProperties": true
208
+ },
209
+ "VerifiedAttributesQueryRequest": {
210
+ "type": "object",
211
+ "properties": {
212
+ "query": { "type": "string" },
213
+ "mode": { "type": "string", "enum": ["natural", "structured"] },
214
+ "proof": {
215
+ "type": "object",
216
+ "properties": {
217
+ "required": { "type": "boolean" },
218
+ "type": { "type": "string", "enum": ["zk-snark", "opaque"] }
219
+ },
220
+ "required": ["required"],
221
+ "additionalProperties": true
222
+ },
223
+ "targets": {
224
+ "type": "object",
225
+ "properties": { "schemas": { "type": "array", "items": { "type": "string" } } },
226
+ "additionalProperties": true
227
+ }
228
+ },
229
+ "required": ["query", "mode"],
230
+ "additionalProperties": false
231
+ },
232
+ "VerifiedAttributesQueryResponseItem": {
233
+ "type": "object",
234
+ "properties": {
235
+ "docHash": { "type": "string" },
236
+ "schema": { "type": "string" },
237
+ "issuerId": { "type": "string" },
238
+ "subjectId": { "type": "string" },
239
+ "attributes": { "type": "object", "additionalProperties": true },
240
+ "proof": {
241
+ "type": "object",
242
+ "properties": { "status": { "type": "string" }, "circuitId": { "type": "string" } },
243
+ "additionalProperties": true
244
+ },
245
+ "disclosure": { "$ref": "#/components/schemas/SelectiveDisclosure" }
246
+ },
247
+ "required": ["docHash", "schema", "issuerId", "subjectId", "attributes"],
248
+ "additionalProperties": true
249
+ },
250
+ "VerifiedAttributesQueryResponse": {
251
+ "type": "object",
252
+ "properties": {
253
+ "results": {
254
+ "type": "array",
255
+ "items": { "$ref": "#/components/schemas/VerifiedAttributesQueryResponseItem" }
256
+ }
257
+ },
258
+ "required": ["results"],
259
+ "additionalProperties": false
260
+ }
261
+ }
262
+ },
263
+ "security": [{ "ApiKeyAuth": [] }],
264
+ "paths": {
265
+ "/v1/health": {
266
+ "get": {
267
+ "security": [],
268
+ "responses": {
269
+ "200": {
270
+ "description": "OK",
271
+ "content": {
272
+ "application/json": {
273
+ "schema": {
274
+ "type": "object",
275
+ "properties": { "ok": { "type": "boolean" } },
276
+ "required": ["ok"]
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
282
+ }
283
+ },
284
+ "/v1/schemas": {
285
+ "post": {
286
+ "requestBody": {
287
+ "required": true,
288
+ "content": {
289
+ "application/json": { "schema": { "$ref": "#/components/schemas/SchemaMeta" } }
290
+ }
291
+ },
292
+ "responses": {
293
+ "200": {
294
+ "description": "Registered",
295
+ "content": {
296
+ "application/json": { "schema": { "$ref": "#/components/schemas/SchemaMeta" } }
297
+ }
298
+ },
299
+ "400": {
300
+ "description": "Bad Request",
301
+ "content": {
302
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
303
+ }
304
+ }
305
+ }
306
+ }
307
+ },
308
+ "/v1/schemas/{id}": {
309
+ "get": {
310
+ "parameters": [
311
+ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
312
+ ],
313
+ "responses": {
314
+ "200": {
315
+ "description": "Found",
316
+ "content": {
317
+ "application/json": { "schema": { "$ref": "#/components/schemas/SchemaMeta" } }
318
+ }
319
+ },
320
+ "404": {
321
+ "description": "Not Found",
322
+ "content": {
323
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
324
+ }
325
+ }
326
+ }
327
+ }
328
+ },
329
+ "/v1/circuits": {
330
+ "post": {
331
+ "requestBody": {
332
+ "required": true,
333
+ "content": {
334
+ "application/json": { "schema": { "$ref": "#/components/schemas/CircuitMeta" } }
335
+ }
336
+ },
337
+ "responses": {
338
+ "200": {
339
+ "description": "Registered",
340
+ "content": {
341
+ "application/json": { "schema": { "$ref": "#/components/schemas/CircuitMeta" } }
342
+ }
343
+ },
344
+ "400": {
345
+ "description": "Bad Request",
346
+ "content": {
347
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
348
+ }
349
+ }
350
+ }
351
+ }
352
+ },
353
+ "/v1/circuits/{circuitId}": {
354
+ "get": {
355
+ "parameters": [
356
+ { "name": "circuitId", "in": "path", "required": true, "schema": { "type": "string" } }
357
+ ],
358
+ "responses": {
359
+ "200": {
360
+ "description": "Found",
361
+ "content": {
362
+ "application/json": { "schema": { "$ref": "#/components/schemas/CircuitMeta" } }
363
+ }
364
+ },
365
+ "404": {
366
+ "description": "Not Found",
367
+ "content": {
368
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
369
+ }
370
+ }
371
+ }
372
+ }
373
+ },
374
+ "/v1/doc-generators": {
375
+ "post": {
376
+ "requestBody": {
377
+ "required": true,
378
+ "content": {
379
+ "application/json": { "schema": { "$ref": "#/components/schemas/GeneratorMeta" } }
380
+ }
381
+ },
382
+ "responses": {
383
+ "200": {
384
+ "description": "Registered",
385
+ "content": {
386
+ "application/json": { "schema": { "$ref": "#/components/schemas/GeneratorMeta" } }
387
+ }
388
+ },
389
+ "400": {
390
+ "description": "Bad Request",
391
+ "content": {
392
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
393
+ }
394
+ }
395
+ }
396
+ }
397
+ },
398
+ "/v1/doc-generators/{generatorId}": {
399
+ "get": {
400
+ "parameters": [
401
+ { "name": "generatorId", "in": "path", "required": true, "schema": { "type": "string" } }
402
+ ],
403
+ "responses": {
404
+ "200": {
405
+ "description": "Found",
406
+ "content": {
407
+ "application/json": { "schema": { "$ref": "#/components/schemas/GeneratorMeta" } }
408
+ }
409
+ },
410
+ "404": {
411
+ "description": "Not Found",
412
+ "content": {
413
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
414
+ }
415
+ }
416
+ }
417
+ }
418
+ },
419
+ "/v1/documents": {
420
+ "post": {
421
+ "requestBody": {
422
+ "required": true,
423
+ "content": {
424
+ "application/json": {
425
+ "schema": { "$ref": "#/components/schemas/RegisterDocumentRequest" }
426
+ }
427
+ }
428
+ },
429
+ "responses": {
430
+ "200": {
431
+ "description": "Registered",
432
+ "content": {
433
+ "application/json": {
434
+ "schema": { "$ref": "#/components/schemas/RegisterDocumentResponse" }
435
+ }
436
+ }
437
+ },
438
+ "400": {
439
+ "description": "Bad Request",
440
+ "content": {
441
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ },
447
+ "/v1/proofs": {
448
+ "post": {
449
+ "requestBody": {
450
+ "required": true,
451
+ "content": {
452
+ "application/json": { "schema": { "$ref": "#/components/schemas/SubmitProofRequest" } }
453
+ }
454
+ },
455
+ "responses": {
456
+ "200": {
457
+ "description": "Submitted",
458
+ "content": {
459
+ "application/json": {
460
+ "schema": { "$ref": "#/components/schemas/SubmitProofResponse" }
461
+ }
462
+ }
463
+ },
464
+ "400": {
465
+ "description": "Bad Request",
466
+ "content": {
467
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
468
+ }
469
+ }
470
+ }
471
+ }
472
+ },
473
+ "/v1/verified-attributes/query": {
474
+ "post": {
475
+ "requestBody": {
476
+ "required": true,
477
+ "content": {
478
+ "application/json": {
479
+ "schema": { "$ref": "#/components/schemas/VerifiedAttributesQueryRequest" }
480
+ }
481
+ }
482
+ },
483
+ "responses": {
484
+ "200": {
485
+ "description": "Results",
486
+ "content": {
487
+ "application/json": {
488
+ "schema": { "$ref": "#/components/schemas/VerifiedAttributesQueryResponse" }
489
+ }
490
+ }
491
+ },
492
+ "400": {
493
+ "description": "Bad Request",
494
+ "content": {
495
+ "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
496
+ }
497
+ }
498
+ }
499
+ }
500
+ }
501
+ }
502
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@lemmaoracle/spec",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "openapi.lemma.v2.json"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "lint": "eslint 'src/**/*.ts'",
14
+ "test": "vitest run"
15
+ },
16
+ "devDependencies": {
17
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
18
+ "@typescript-eslint/parser": "^8.56.1",
19
+ "eslint": "^9.39.3",
20
+ "eslint-config-prettier": "^9.1.0",
21
+ "eslint-plugin-functional": "^9.0.4",
22
+ "typescript": "^5.5.0",
23
+ "vitest": "^2.1.0"
24
+ }
25
+ }