@parmanasystems/sdk-client 1.0.19 → 1.4.0

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/dist/index.d.ts CHANGED
@@ -1,406 +1,406 @@
1
- /**
2
- * This file was auto-generated by openapi-typescript.
3
- * Do not make direct changes to the file.
4
- */
5
-
6
- interface paths {
7
- "/health": {
8
- parameters: {
9
- query?: never;
10
- header?: never;
11
- path?: never;
12
- cookie?: never;
13
- };
14
- /** Health check */
15
- get: {
16
- parameters: {
17
- query?: never;
18
- header?: never;
19
- path?: never;
20
- cookie?: never;
21
- };
22
- requestBody?: never;
23
- responses: {
24
- /** @description Server is healthy */
25
- 200: {
26
- headers: {
27
- [name: string]: unknown;
28
- };
29
- content: {
30
- "application/json": {
31
- /** @enum {string} */
32
- status: "ok";
33
- version: string;
34
- /** Format: date-time */
35
- timestamp: string;
36
- };
37
- };
38
- };
39
- };
40
- };
41
- put?: never;
42
- post?: never;
43
- delete?: never;
44
- options?: never;
45
- head?: never;
46
- patch?: never;
47
- trace?: never;
48
- };
49
- "/execute": {
50
- parameters: {
51
- query?: never;
52
- header?: never;
53
- path?: never;
54
- cookie?: never;
55
- };
56
- get?: never;
57
- put?: never;
58
- /**
59
- * Execute a governance decision
60
- * @description Issues an execution token, runs the deterministic governance runtime, and returns a signed ExecutionAttestation.
61
- */
62
- post: {
63
- parameters: {
64
- query?: never;
65
- header?: never;
66
- path?: never;
67
- cookie?: never;
68
- };
69
- requestBody: {
70
- content: {
71
- "application/json": {
72
- /** @description Policy identifier */
73
- policy_id: string;
74
- /** @description Semantic version of the policy */
75
- policy_version: string;
76
- /** @description Decision type to execute (e.g. approve, deny) */
77
- decision_type: string;
78
- /** @description SHA-256 hex digest of the input signals payload */
79
- signals_hash: string;
80
- };
81
- };
82
- };
83
- responses: {
84
- /** @description Signed execution attestation */
85
- 200: {
86
- headers: {
87
- [name: string]: unknown;
88
- };
89
- content: {
90
- "application/json": {
91
- result: {
92
- /** Format: uuid */
93
- execution_id: string;
94
- policy_id: string;
95
- policy_version: string;
96
- schema_version: string;
97
- runtime_version: string;
98
- runtime_hash: string;
99
- decision: string;
100
- signals_hash: string;
101
- /** Format: date-time */
102
- executed_at: string;
103
- };
104
- /** @description Base64 Ed25519 signature over the result */
105
- signature: string;
106
- };
107
- };
108
- };
109
- /** @description Missing or invalid request fields */
110
- 400: {
111
- headers: {
112
- [name: string]: unknown;
113
- };
114
- content: {
115
- "application/json": {
116
- error: string;
117
- };
118
- };
119
- };
120
- /** @description Execution failed (policy not found, token expired, replay detected) */
121
- 422: {
122
- headers: {
123
- [name: string]: unknown;
124
- };
125
- content: {
126
- "application/json": {
127
- error: string;
128
- };
129
- };
130
- };
131
- };
132
- };
133
- delete?: never;
134
- options?: never;
135
- head?: never;
136
- patch?: never;
137
- trace?: never;
138
- };
139
- "/verify": {
140
- parameters: {
141
- query?: never;
142
- header?: never;
143
- path?: never;
144
- cookie?: never;
145
- };
146
- get?: never;
147
- put?: never;
148
- /**
149
- * Verify an execution attestation
150
- * @description Checks the cryptographic signature, runtime hash, and schema version of an attestation produced by POST /execute.
151
- */
152
- post: {
153
- parameters: {
154
- query?: never;
155
- header?: never;
156
- path?: never;
157
- cookie?: never;
158
- };
159
- /** @description An ExecutionAttestation as returned by POST /execute */
160
- requestBody: {
161
- content: {
162
- "application/json": {
163
- result: {
164
- /** Format: uuid */
165
- execution_id: string;
166
- policy_id: string;
167
- policy_version: string;
168
- schema_version: string;
169
- runtime_version: string;
170
- runtime_hash: string;
171
- decision: string;
172
- signals_hash: string;
173
- /** Format: date-time */
174
- executed_at: string;
175
- };
176
- /** @description Base64 Ed25519 signature over the result */
177
- signature: string;
178
- };
179
- };
180
- };
181
- responses: {
182
- /** @description Verification result with per-check breakdown */
183
- 200: {
184
- headers: {
185
- [name: string]: unknown;
186
- };
187
- content: {
188
- "application/json": {
189
- valid: boolean;
190
- checks: {
191
- signature_verified: boolean;
192
- runtime_verified: boolean;
193
- schema_compatible: boolean;
194
- };
195
- };
196
- };
197
- };
198
- /** @description Malformed attestation body */
199
- 400: {
200
- headers: {
201
- [name: string]: unknown;
202
- };
203
- content: {
204
- "application/json": {
205
- error: string;
206
- };
207
- };
208
- };
209
- /** @description Verification threw an unexpected error */
210
- 422: {
211
- headers: {
212
- [name: string]: unknown;
213
- };
214
- content: {
215
- "application/json": {
216
- error: string;
217
- };
218
- };
219
- };
220
- };
221
- };
222
- delete?: never;
223
- options?: never;
224
- head?: never;
225
- patch?: never;
226
- trace?: never;
227
- };
228
- "/runtime/manifest": {
229
- parameters: {
230
- query?: never;
231
- header?: never;
232
- path?: never;
233
- cookie?: never;
234
- };
235
- /**
236
- * Runtime bundle manifest
237
- * @description Returns the signed bundle manifest for the active governance runtime.
238
- */
239
- get: {
240
- parameters: {
241
- query?: never;
242
- header?: never;
243
- path?: never;
244
- cookie?: never;
245
- };
246
- requestBody?: never;
247
- responses: {
248
- /** @description Not yet implemented */
249
- 501: {
250
- headers: {
251
- [name: string]: unknown;
252
- };
253
- content: {
254
- "application/json": {
255
- /** @enum {string} */
256
- error: "Not implemented";
257
- };
258
- };
259
- };
260
- };
261
- };
262
- put?: never;
263
- post?: never;
264
- delete?: never;
265
- options?: never;
266
- head?: never;
267
- patch?: never;
268
- trace?: never;
269
- };
270
- "/runtime/capabilities": {
271
- parameters: {
272
- query?: never;
273
- header?: never;
274
- path?: never;
275
- cookie?: never;
276
- };
277
- /**
278
- * Runtime capability declarations
279
- * @description Lists the capabilities supported by this runtime instance.
280
- */
281
- get: {
282
- parameters: {
283
- query?: never;
284
- header?: never;
285
- path?: never;
286
- cookie?: never;
287
- };
288
- requestBody?: never;
289
- responses: {
290
- /** @description Not yet implemented */
291
- 501: {
292
- headers: {
293
- [name: string]: unknown;
294
- };
295
- content: {
296
- "application/json": {
297
- /** @enum {string} */
298
- error: "Not implemented";
299
- };
300
- };
301
- };
302
- };
303
- };
304
- put?: never;
305
- post?: never;
306
- delete?: never;
307
- options?: never;
308
- head?: never;
309
- patch?: never;
310
- trace?: never;
311
- };
312
- "/evaluate": {
313
- parameters: {
314
- query?: never;
315
- header?: never;
316
- path?: never;
317
- cookie?: never;
318
- };
319
- get?: never;
320
- put?: never;
321
- /**
322
- * Evaluate a policy without executing
323
- * @description Dry-run policy evaluation — computes a decision without issuing an attestation or consuming a replay slot.
324
- */
325
- post: {
326
- parameters: {
327
- query?: never;
328
- header?: never;
329
- path?: never;
330
- cookie?: never;
331
- };
332
- requestBody: {
333
- content: {
334
- "application/json": Record<string, never>;
335
- };
336
- };
337
- responses: {
338
- /** @description Not yet implemented */
339
- 501: {
340
- headers: {
341
- [name: string]: unknown;
342
- };
343
- content: {
344
- "application/json": {
345
- /** @enum {string} */
346
- error: "Not implemented";
347
- };
348
- };
349
- };
350
- };
351
- };
352
- delete?: never;
353
- options?: never;
354
- head?: never;
355
- patch?: never;
356
- trace?: never;
357
- };
358
- "/simulate": {
359
- parameters: {
360
- query?: never;
361
- header?: never;
362
- path?: never;
363
- cookie?: never;
364
- };
365
- get?: never;
366
- put?: never;
367
- /**
368
- * Simulate a governance decision dry-run
369
- * @description Runs the full execution pipeline in simulation mode — no side effects, no attestation produced.
370
- */
371
- post: {
372
- parameters: {
373
- query?: never;
374
- header?: never;
375
- path?: never;
376
- cookie?: never;
377
- };
378
- requestBody: {
379
- content: {
380
- "application/json": Record<string, never>;
381
- };
382
- };
383
- responses: {
384
- /** @description Not yet implemented */
385
- 501: {
386
- headers: {
387
- [name: string]: unknown;
388
- };
389
- content: {
390
- "application/json": {
391
- /** @enum {string} */
392
- error: "Not implemented";
393
- };
394
- };
395
- };
396
- };
397
- };
398
- delete?: never;
399
- options?: never;
400
- head?: never;
401
- patch?: never;
402
- trace?: never;
403
- };
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ interface paths {
7
+ "/health": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ /** Health check */
15
+ get: {
16
+ parameters: {
17
+ query?: never;
18
+ header?: never;
19
+ path?: never;
20
+ cookie?: never;
21
+ };
22
+ requestBody?: never;
23
+ responses: {
24
+ /** @description Server is healthy */
25
+ 200: {
26
+ headers: {
27
+ [name: string]: unknown;
28
+ };
29
+ content: {
30
+ "application/json": {
31
+ /** @enum {string} */
32
+ status: "ok";
33
+ version: string;
34
+ /** Format: date-time */
35
+ timestamp: string;
36
+ };
37
+ };
38
+ };
39
+ };
40
+ };
41
+ put?: never;
42
+ post?: never;
43
+ delete?: never;
44
+ options?: never;
45
+ head?: never;
46
+ patch?: never;
47
+ trace?: never;
48
+ };
49
+ "/execute": {
50
+ parameters: {
51
+ query?: never;
52
+ header?: never;
53
+ path?: never;
54
+ cookie?: never;
55
+ };
56
+ get?: never;
57
+ put?: never;
58
+ /**
59
+ * Execute a governance decision
60
+ * @description Issues an execution token, runs the deterministic governance runtime, and returns a signed ExecutionAttestation.
61
+ */
62
+ post: {
63
+ parameters: {
64
+ query?: never;
65
+ header?: never;
66
+ path?: never;
67
+ cookie?: never;
68
+ };
69
+ requestBody: {
70
+ content: {
71
+ "application/json": {
72
+ /** @description Policy identifier */
73
+ policy_id: string;
74
+ /** @description Semantic version of the policy */
75
+ policy_version: string;
76
+ /** @description Decision type to execute (e.g. approve, deny) */
77
+ decision_type: string;
78
+ /** @description SHA-256 hex digest of the input signals payload */
79
+ signals_hash: string;
80
+ };
81
+ };
82
+ };
83
+ responses: {
84
+ /** @description Signed execution attestation */
85
+ 200: {
86
+ headers: {
87
+ [name: string]: unknown;
88
+ };
89
+ content: {
90
+ "application/json": {
91
+ result: {
92
+ /** Format: uuid */
93
+ execution_id: string;
94
+ policy_id: string;
95
+ policy_version: string;
96
+ schema_version: string;
97
+ runtime_version: string;
98
+ runtime_hash: string;
99
+ decision: string;
100
+ signals_hash: string;
101
+ /** Format: date-time */
102
+ executed_at: string;
103
+ };
104
+ /** @description Base64 Ed25519 signature over the result */
105
+ signature: string;
106
+ };
107
+ };
108
+ };
109
+ /** @description Missing or invalid request fields */
110
+ 400: {
111
+ headers: {
112
+ [name: string]: unknown;
113
+ };
114
+ content: {
115
+ "application/json": {
116
+ error: string;
117
+ };
118
+ };
119
+ };
120
+ /** @description Execution failed (policy not found, token expired, replay detected) */
121
+ 422: {
122
+ headers: {
123
+ [name: string]: unknown;
124
+ };
125
+ content: {
126
+ "application/json": {
127
+ error: string;
128
+ };
129
+ };
130
+ };
131
+ };
132
+ };
133
+ delete?: never;
134
+ options?: never;
135
+ head?: never;
136
+ patch?: never;
137
+ trace?: never;
138
+ };
139
+ "/verify": {
140
+ parameters: {
141
+ query?: never;
142
+ header?: never;
143
+ path?: never;
144
+ cookie?: never;
145
+ };
146
+ get?: never;
147
+ put?: never;
148
+ /**
149
+ * Verify an execution attestation
150
+ * @description Checks the cryptographic signature, runtime hash, and schema version of an attestation produced by POST /execute.
151
+ */
152
+ post: {
153
+ parameters: {
154
+ query?: never;
155
+ header?: never;
156
+ path?: never;
157
+ cookie?: never;
158
+ };
159
+ /** @description An ExecutionAttestation as returned by POST /execute */
160
+ requestBody: {
161
+ content: {
162
+ "application/json": {
163
+ result: {
164
+ /** Format: uuid */
165
+ execution_id: string;
166
+ policy_id: string;
167
+ policy_version: string;
168
+ schema_version: string;
169
+ runtime_version: string;
170
+ runtime_hash: string;
171
+ decision: string;
172
+ signals_hash: string;
173
+ /** Format: date-time */
174
+ executed_at: string;
175
+ };
176
+ /** @description Base64 Ed25519 signature over the result */
177
+ signature: string;
178
+ };
179
+ };
180
+ };
181
+ responses: {
182
+ /** @description Verification result with per-check breakdown */
183
+ 200: {
184
+ headers: {
185
+ [name: string]: unknown;
186
+ };
187
+ content: {
188
+ "application/json": {
189
+ valid: boolean;
190
+ checks: {
191
+ signature_verified: boolean;
192
+ runtime_verified: boolean;
193
+ schema_compatible: boolean;
194
+ };
195
+ };
196
+ };
197
+ };
198
+ /** @description Malformed attestation body */
199
+ 400: {
200
+ headers: {
201
+ [name: string]: unknown;
202
+ };
203
+ content: {
204
+ "application/json": {
205
+ error: string;
206
+ };
207
+ };
208
+ };
209
+ /** @description Verification threw an unexpected error */
210
+ 422: {
211
+ headers: {
212
+ [name: string]: unknown;
213
+ };
214
+ content: {
215
+ "application/json": {
216
+ error: string;
217
+ };
218
+ };
219
+ };
220
+ };
221
+ };
222
+ delete?: never;
223
+ options?: never;
224
+ head?: never;
225
+ patch?: never;
226
+ trace?: never;
227
+ };
228
+ "/runtime/manifest": {
229
+ parameters: {
230
+ query?: never;
231
+ header?: never;
232
+ path?: never;
233
+ cookie?: never;
234
+ };
235
+ /**
236
+ * Runtime bundle manifest
237
+ * @description Returns the signed bundle manifest for the active governance runtime.
238
+ */
239
+ get: {
240
+ parameters: {
241
+ query?: never;
242
+ header?: never;
243
+ path?: never;
244
+ cookie?: never;
245
+ };
246
+ requestBody?: never;
247
+ responses: {
248
+ /** @description Not yet implemented */
249
+ 501: {
250
+ headers: {
251
+ [name: string]: unknown;
252
+ };
253
+ content: {
254
+ "application/json": {
255
+ /** @enum {string} */
256
+ error: "Not implemented";
257
+ };
258
+ };
259
+ };
260
+ };
261
+ };
262
+ put?: never;
263
+ post?: never;
264
+ delete?: never;
265
+ options?: never;
266
+ head?: never;
267
+ patch?: never;
268
+ trace?: never;
269
+ };
270
+ "/runtime/capabilities": {
271
+ parameters: {
272
+ query?: never;
273
+ header?: never;
274
+ path?: never;
275
+ cookie?: never;
276
+ };
277
+ /**
278
+ * Runtime capability declarations
279
+ * @description Lists the capabilities supported by this runtime instance.
280
+ */
281
+ get: {
282
+ parameters: {
283
+ query?: never;
284
+ header?: never;
285
+ path?: never;
286
+ cookie?: never;
287
+ };
288
+ requestBody?: never;
289
+ responses: {
290
+ /** @description Not yet implemented */
291
+ 501: {
292
+ headers: {
293
+ [name: string]: unknown;
294
+ };
295
+ content: {
296
+ "application/json": {
297
+ /** @enum {string} */
298
+ error: "Not implemented";
299
+ };
300
+ };
301
+ };
302
+ };
303
+ };
304
+ put?: never;
305
+ post?: never;
306
+ delete?: never;
307
+ options?: never;
308
+ head?: never;
309
+ patch?: never;
310
+ trace?: never;
311
+ };
312
+ "/evaluate": {
313
+ parameters: {
314
+ query?: never;
315
+ header?: never;
316
+ path?: never;
317
+ cookie?: never;
318
+ };
319
+ get?: never;
320
+ put?: never;
321
+ /**
322
+ * Evaluate a policy without executing
323
+ * @description Dry-run policy evaluation — computes a decision without issuing an attestation or consuming a replay slot.
324
+ */
325
+ post: {
326
+ parameters: {
327
+ query?: never;
328
+ header?: never;
329
+ path?: never;
330
+ cookie?: never;
331
+ };
332
+ requestBody: {
333
+ content: {
334
+ "application/json": Record<string, never>;
335
+ };
336
+ };
337
+ responses: {
338
+ /** @description Not yet implemented */
339
+ 501: {
340
+ headers: {
341
+ [name: string]: unknown;
342
+ };
343
+ content: {
344
+ "application/json": {
345
+ /** @enum {string} */
346
+ error: "Not implemented";
347
+ };
348
+ };
349
+ };
350
+ };
351
+ };
352
+ delete?: never;
353
+ options?: never;
354
+ head?: never;
355
+ patch?: never;
356
+ trace?: never;
357
+ };
358
+ "/simulate": {
359
+ parameters: {
360
+ query?: never;
361
+ header?: never;
362
+ path?: never;
363
+ cookie?: never;
364
+ };
365
+ get?: never;
366
+ put?: never;
367
+ /**
368
+ * Simulate a governance decision dry-run
369
+ * @description Runs the full execution pipeline in simulation mode — no side effects, no attestation produced.
370
+ */
371
+ post: {
372
+ parameters: {
373
+ query?: never;
374
+ header?: never;
375
+ path?: never;
376
+ cookie?: never;
377
+ };
378
+ requestBody: {
379
+ content: {
380
+ "application/json": Record<string, never>;
381
+ };
382
+ };
383
+ responses: {
384
+ /** @description Not yet implemented */
385
+ 501: {
386
+ headers: {
387
+ [name: string]: unknown;
388
+ };
389
+ content: {
390
+ "application/json": {
391
+ /** @enum {string} */
392
+ error: "Not implemented";
393
+ };
394
+ };
395
+ };
396
+ };
397
+ };
398
+ delete?: never;
399
+ options?: never;
400
+ head?: never;
401
+ patch?: never;
402
+ trace?: never;
403
+ };
404
404
  }
405
405
 
406
406
  /** Response body for GET /health */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\n HealthResponse,\n ExecuteRequest,\n ExecutionAttestation,\n VerificationResult,\n} from \"./types.js\";\n\n/** Construction options for {@link ParmanaClient}. */\nexport interface ParmanaClientOptions {\n /** Base URL of the parmanasystems server, e.g. `\"http://localhost:3000\"`. Trailing slashes are stripped. */\n baseUrl: string;\n /** Bearer token for API authentication — required when the server has `Parmana_API_KEY` set. */\n apiKey?: string;\n}\n\n/**\n * Thrown by {@link ParmanaClient} whenever the server returns a non-2xx HTTP status.\n * The `status` property holds the HTTP status code; `message` contains the\n * server's `error` field (or `statusText` as a fallback).\n */\nexport class ParmanaApiError extends Error {\n /** HTTP status code returned by the server. */\n readonly status: number;\n\n constructor(status: number, message: string) {\n super(message);\n this.name = \"ParmanaApiError\";\n this.status = status;\n }\n}\n\n/**\n * Type-safe HTTP client for the parmanasystems governance REST API.\n *\n * All request and response types are derived directly from the generated\n * `openapi.d.ts` spec, so they stay in sync with the server automatically.\n *\n * @example\n * ```ts\n * const client = new ParmanaClient({ baseUrl: \"http://localhost:3000\", apiKey: \"secret\" });\n *\n * const attestation = await client.execute({\n * policy_id: \"access-control\",\n * policy_version: \"v1\",\n * decision_type: \"approve\",\n * signals_hash: \"abc123...\",\n * });\n *\n * const result = await client.verify(attestation);\n * console.log(result.valid); // true\n * ```\n */\nexport class ParmanaClient {\n private readonly baseUrl: string;\n private readonly defaultHeaders: Record<string, string>;\n\n /** @param options - Client configuration including the server URL and optional API key. */\n constructor(options: ParmanaClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\n this.defaultHeaders = {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\",\n ...(options.apiKey\n ? { Authorization: `Bearer ${options.apiKey}` }\n : {}),\n };\n }\n\n private async request<TRes>(\n path: string,\n init?: RequestInit\n ): Promise<TRes> {\n const res = await fetch(`${this.baseUrl}${path}`, {\n ...init,\n headers: {\n ...this.defaultHeaders,\n ...(init?.headers ?? {}),\n },\n });\n\n const body: unknown = await res.json();\n\n if (!res.ok) {\n const message =\n body !== null &&\n typeof body === \"object\" &&\n \"error\" in body &&\n typeof (body as { error: unknown }).error === \"string\"\n ? (body as { error: string }).error\n : res.statusText;\n throw new ParmanaApiError(res.status, message);\n }\n\n return body as TRes;\n }\n\n /** GET /health — returns runtime status and version. */\n async health(): Promise<HealthResponse> {\n return this.request<HealthResponse>(\"/health\");\n }\n\n /**\n * POST /execute — runs the deterministic governance runtime and returns\n * a signed ExecutionAttestation. The returned value can be passed\n * directly to verify().\n */\n async execute(request: ExecuteRequest): Promise<ExecutionAttestation> {\n return this.request<ExecutionAttestation>(\"/execute\", {\n method: \"POST\",\n body: JSON.stringify(request),\n });\n }\n\n /**\n * POST /verify — independently verifies an ExecutionAttestation.\n * Pass the object returned by execute() straight into this method.\n */\n async verify(attestation: ExecutionAttestation): Promise<VerificationResult> {\n return this.request<VerificationResult>(\"/verify\", {\n method: \"POST\",\n body: JSON.stringify(attestation),\n });\n }\n}\n"],"mappings":";AAoBO,IAAM,kBAAN,cAA8B,MAAM;AAAA;AAAA,EAEhC;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAuBO,IAAM,gBAAN,MAAoB;AAAA,EACR;AAAA,EACA;AAAA;AAAA,EAGjB,YAAY,SAA+B;AACzC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,iBAAiB;AAAA,MACpB,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,GAAI,QAAQ,SACR,EAAE,eAAe,UAAU,QAAQ,MAAM,GAAG,IAC5C,CAAC;AAAA,IACP;AAAA,EACF;AAAA,EAEA,MAAc,QACZ,MACA,MACe;AACf,UAAM,MAAM,MAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI,IAAI;AAAA,MAChD,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAI,MAAM,WAAW,CAAC;AAAA,MACxB;AAAA,IACF,CAAC;AAED,UAAM,OAAgB,MAAM,IAAI,KAAK;AAErC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,UACJ,SAAS,QACT,OAAO,SAAS,YAChB,WAAW,QACX,OAAQ,KAA4B,UAAU,WACzC,KAA2B,QAC5B,IAAI;AACV,YAAM,IAAI,gBAAgB,IAAI,QAAQ,OAAO;AAAA,IAC/C;AAEA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,SAAkC;AACtC,WAAO,KAAK,QAAwB,SAAS;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ,SAAwD;AACpE,WAAO,KAAK,QAA8B,YAAY;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,aAAgE;AAC3E,WAAO,KAAK,QAA4B,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,WAAW;AAAA,IAClC,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type {\r\n HealthResponse,\r\n ExecuteRequest,\r\n ExecutionAttestation,\r\n VerificationResult,\r\n} from \"./types.js\";\r\n\r\n/** Construction options for {@link ParmanaClient}. */\r\nexport interface ParmanaClientOptions {\r\n /** Base URL of the parmanasystems server, e.g. `\"http://localhost:3000\"`. Trailing slashes are stripped. */\r\n baseUrl: string;\r\n /** Bearer token for API authentication — required when the server has `Parmana_API_KEY` set. */\r\n apiKey?: string;\r\n}\r\n\r\n/**\r\n * Thrown by {@link ParmanaClient} whenever the server returns a non-2xx HTTP status.\r\n * The `status` property holds the HTTP status code; `message` contains the\r\n * server's `error` field (or `statusText` as a fallback).\r\n */\r\nexport class ParmanaApiError extends Error {\r\n /** HTTP status code returned by the server. */\r\n readonly status: number;\r\n\r\n constructor(status: number, message: string) {\r\n super(message);\r\n this.name = \"ParmanaApiError\";\r\n this.status = status;\r\n }\r\n}\r\n\r\n/**\r\n * Type-safe HTTP client for the parmanasystems governance REST API.\r\n *\r\n * All request and response types are derived directly from the generated\r\n * `openapi.d.ts` spec, so they stay in sync with the server automatically.\r\n *\r\n * @example\r\n * ```ts\r\n * const client = new ParmanaClient({ baseUrl: \"http://localhost:3000\", apiKey: \"secret\" });\r\n *\r\n * const attestation = await client.execute({\r\n * policy_id: \"access-control\",\r\n * policy_version: \"v1\",\r\n * decision_type: \"approve\",\r\n * signals_hash: \"abc123...\",\r\n * });\r\n *\r\n * const result = await client.verify(attestation);\r\n * console.log(result.valid); // true\r\n * ```\r\n */\r\nexport class ParmanaClient {\r\n private readonly baseUrl: string;\r\n private readonly defaultHeaders: Record<string, string>;\r\n\r\n /** @param options - Client configuration including the server URL and optional API key. */\r\n constructor(options: ParmanaClientOptions) {\r\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\r\n this.defaultHeaders = {\r\n \"Content-Type\": \"application/json\",\r\n \"Accept\": \"application/json\",\r\n ...(options.apiKey\r\n ? { Authorization: `Bearer ${options.apiKey}` }\r\n : {}),\r\n };\r\n }\r\n\r\n private async request<TRes>(\r\n path: string,\r\n init?: RequestInit\r\n ): Promise<TRes> {\r\n const res = await fetch(`${this.baseUrl}${path}`, {\r\n ...init,\r\n headers: {\r\n ...this.defaultHeaders,\r\n ...(init?.headers ?? {}),\r\n },\r\n });\r\n\r\n const body: unknown = await res.json();\r\n\r\n if (!res.ok) {\r\n const message =\r\n body !== null &&\r\n typeof body === \"object\" &&\r\n \"error\" in body &&\r\n typeof (body as { error: unknown }).error === \"string\"\r\n ? (body as { error: string }).error\r\n : res.statusText;\r\n throw new ParmanaApiError(res.status, message);\r\n }\r\n\r\n return body as TRes;\r\n }\r\n\r\n /** GET /health — returns runtime status and version. */\r\n async health(): Promise<HealthResponse> {\r\n return this.request<HealthResponse>(\"/health\");\r\n }\r\n\r\n /**\r\n * POST /execute — runs the deterministic governance runtime and returns\r\n * a signed ExecutionAttestation. The returned value can be passed\r\n * directly to verify().\r\n */\r\n async execute(request: ExecuteRequest): Promise<ExecutionAttestation> {\r\n return this.request<ExecutionAttestation>(\"/execute\", {\r\n method: \"POST\",\r\n body: JSON.stringify(request),\r\n });\r\n }\r\n\r\n /**\r\n * POST /verify — independently verifies an ExecutionAttestation.\r\n * Pass the object returned by execute() straight into this method.\r\n */\r\n async verify(attestation: ExecutionAttestation): Promise<VerificationResult> {\r\n return this.request<VerificationResult>(\"/verify\", {\r\n method: \"POST\",\r\n body: JSON.stringify(attestation),\r\n });\r\n }\r\n}\r\n"],"mappings":";AAoBO,IAAM,kBAAN,cAA8B,MAAM;AAAA;AAAA,EAEhC;AAAA,EAET,YAAY,QAAgB,SAAiB;AAC3C,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAuBO,IAAM,gBAAN,MAAoB;AAAA,EACR;AAAA,EACA;AAAA;AAAA,EAGjB,YAAY,SAA+B;AACzC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,iBAAiB;AAAA,MACpB,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,GAAI,QAAQ,SACR,EAAE,eAAe,UAAU,QAAQ,MAAM,GAAG,IAC5C,CAAC;AAAA,IACP;AAAA,EACF;AAAA,EAEA,MAAc,QACZ,MACA,MACe;AACf,UAAM,MAAM,MAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI,IAAI;AAAA,MAChD,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAI,MAAM,WAAW,CAAC;AAAA,MACxB;AAAA,IACF,CAAC;AAED,UAAM,OAAgB,MAAM,IAAI,KAAK;AAErC,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,UACJ,SAAS,QACT,OAAO,SAAS,YAChB,WAAW,QACX,OAAQ,KAA4B,UAAU,WACzC,KAA2B,QAC5B,IAAI;AACV,YAAM,IAAI,gBAAgB,IAAI,QAAQ,OAAO;AAAA,IAC/C;AAEA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,SAAkC;AACtC,WAAO,KAAK,QAAwB,SAAS;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,QAAQ,SAAwD;AACpE,WAAO,KAAK,QAA8B,YAAY;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,aAAgE;AAC3E,WAAO,KAAK,QAA4B,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,WAAW;AAAA,IAClC,CAAC;AAAA,EACH;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parmanasystems/sdk-client",
3
- "version": "1.0.19",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Type-safe SDK client for the parmanasystems Runtime API.",