@parmanasystems/sdk-client 1.0.19
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 +179 -0
- package/dist/index.d.ts +478 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# @parmanasystems/sdk-client
|
|
2
|
+
|
|
3
|
+
Type-safe fetch client for the parmanasystems governance server.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@parmanasystems/sdk-client)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
`@parmanasystems/sdk-client` is a zero-dependency TypeScript client for `@parmanasystems/server`. Types are generated directly from `openapi.json` using `openapi-typescript`, so the client types are always in sync with the server API.
|
|
12
|
+
|
|
13
|
+
- **Zero runtime dependencies** — native `fetch` only
|
|
14
|
+
- **Fully typed** — all request bodies, responses, and error types are inferred from the OpenAPI spec
|
|
15
|
+
- **Throws on non-2xx** — errors surface as `ParmanaApiError` with the HTTP status code attached
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @parmanasystems/sdk-client
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Requires Node.js ≥ 20 (for native `fetch`) or any environment with a global `fetch` implementation.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { ParmanaClient } from "@parmanasystems/sdk-client";
|
|
33
|
+
|
|
34
|
+
const client = new ParmanaClient({
|
|
35
|
+
baseUrl: "http://localhost:3000",
|
|
36
|
+
// apiKey: "my-secret-key", // include if Parmana_API_KEY is set on the server
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Check server health
|
|
40
|
+
const health = await client.health();
|
|
41
|
+
console.log(health.status); // "ok"
|
|
42
|
+
console.log(health.version); // "1.0.0"
|
|
43
|
+
|
|
44
|
+
// Execute a governance decision
|
|
45
|
+
const attestation = await client.execute({
|
|
46
|
+
policy_id: "loan-approval",
|
|
47
|
+
policy_version: "v1",
|
|
48
|
+
decision_type: "approve",
|
|
49
|
+
signals_hash: "abc123signals",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
console.log(attestation.result.decision); // "approve"
|
|
53
|
+
console.log(attestation.signature); // base64 Ed25519 signature
|
|
54
|
+
|
|
55
|
+
// Independently verify the attestation
|
|
56
|
+
const verification = await client.verify(attestation);
|
|
57
|
+
console.log(verification.valid); // true
|
|
58
|
+
console.log(verification.checks.signature_verified); // true
|
|
59
|
+
console.log(verification.checks.runtime_verified); // true
|
|
60
|
+
console.log(verification.checks.schema_compatible); // true
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## API
|
|
66
|
+
|
|
67
|
+
### `new ParmanaClient(options)`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const client = new ParmanaClient({
|
|
71
|
+
baseUrl: "https://governance.example.com",
|
|
72
|
+
apiKey: "your-bearer-token", // optional
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Option | Type | Required | Description |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| `baseUrl` | `string` | Yes | Base URL of the parmanasystems server |
|
|
79
|
+
| `apiKey` | `string` | No | Sent as `Authorization: Bearer <apiKey>` |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `client.health(): Promise<HealthResponse>`
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const { status, version, timestamp } = await client.health();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### `client.execute(request): Promise<ExecutionAttestation>`
|
|
92
|
+
|
|
93
|
+
Runs the governance execution pipeline. Returns a signed `ExecutionAttestation`.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const attestation = await client.execute({
|
|
97
|
+
policy_id: "claims-processing",
|
|
98
|
+
policy_version: "v2",
|
|
99
|
+
decision_type: "approve-claim",
|
|
100
|
+
signals_hash: "sha256-of-signals-payload",
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Field | Type | Description |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `policy_id` | `string` | Policy identifier |
|
|
107
|
+
| `policy_version` | `string` | Semantic version of the policy |
|
|
108
|
+
| `decision_type` | `string` | Decision type to execute |
|
|
109
|
+
| `signals_hash` | `string` | SHA-256 hex digest of the input signals |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### `client.verify(attestation): Promise<VerificationResult>`
|
|
114
|
+
|
|
115
|
+
Independently verifies an attestation. Pass the return value from `execute()` directly.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const result = await client.verify(attestation);
|
|
119
|
+
|
|
120
|
+
if (!result.valid) {
|
|
121
|
+
console.error("Attestation verification failed:", result.checks);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Error handling
|
|
128
|
+
|
|
129
|
+
Non-2xx responses throw `ParmanaApiError`:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { ParmanaClient, ParmanaApiError } from "@parmanasystems/sdk-client";
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
await client.execute({ ... });
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (err instanceof ParmanaApiError) {
|
|
138
|
+
console.error(`HTTP ${err.status}: ${err.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`ParmanaApiError.message` is populated from the server's `{ error: string }` response body, or from the HTTP status text if parsing fails.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Types
|
|
148
|
+
|
|
149
|
+
All types are derived via indexed-access from `openapi.d.ts` (generated from `openapi.json`) and re-exported from the package index:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import type {
|
|
153
|
+
HealthResponse,
|
|
154
|
+
ExecuteRequest,
|
|
155
|
+
ExecutionResult,
|
|
156
|
+
ExecutionAttestation,
|
|
157
|
+
VerificationResult,
|
|
158
|
+
ApiErrorBody,
|
|
159
|
+
ParmanaClientOptions,
|
|
160
|
+
} from "@parmanasystems/sdk-client";
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Regenerating types
|
|
166
|
+
|
|
167
|
+
If you modify `openapi.json`, regenerate the type definitions:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
cd packages/sdk-client
|
|
171
|
+
npm run generate # runs: openapi-typescript ../../openapi.json -o src/openapi.d.ts
|
|
172
|
+
npm run build
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
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
|
+
}
|
|
405
|
+
|
|
406
|
+
/** Response body for GET /health */
|
|
407
|
+
type HealthResponse = paths["/health"]["get"]["responses"][200]["content"]["application/json"];
|
|
408
|
+
/** Request body for POST /execute */
|
|
409
|
+
type ExecuteRequest = paths["/execute"]["post"]["requestBody"]["content"]["application/json"];
|
|
410
|
+
/** The inner result record inside an ExecutionAttestation */
|
|
411
|
+
type ExecutionResult = paths["/execute"]["post"]["responses"][200]["content"]["application/json"]["result"];
|
|
412
|
+
/** Response body for POST /execute — pass this directly to verify() */
|
|
413
|
+
type ExecutionAttestation = paths["/execute"]["post"]["responses"][200]["content"]["application/json"];
|
|
414
|
+
/** Response body for POST /verify */
|
|
415
|
+
type VerificationResult = paths["/verify"]["post"]["responses"][200]["content"]["application/json"];
|
|
416
|
+
/** Error body returned on 4xx / 5xx responses */
|
|
417
|
+
type ApiErrorBody = paths["/execute"]["post"]["responses"][400]["content"]["application/json"];
|
|
418
|
+
|
|
419
|
+
/** Construction options for {@link ParmanaClient}. */
|
|
420
|
+
interface ParmanaClientOptions {
|
|
421
|
+
/** Base URL of the parmanasystems server, e.g. `"http://localhost:3000"`. Trailing slashes are stripped. */
|
|
422
|
+
baseUrl: string;
|
|
423
|
+
/** Bearer token for API authentication — required when the server has `Parmana_API_KEY` set. */
|
|
424
|
+
apiKey?: string;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Thrown by {@link ParmanaClient} whenever the server returns a non-2xx HTTP status.
|
|
428
|
+
* The `status` property holds the HTTP status code; `message` contains the
|
|
429
|
+
* server's `error` field (or `statusText` as a fallback).
|
|
430
|
+
*/
|
|
431
|
+
declare class ParmanaApiError extends Error {
|
|
432
|
+
/** HTTP status code returned by the server. */
|
|
433
|
+
readonly status: number;
|
|
434
|
+
constructor(status: number, message: string);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Type-safe HTTP client for the parmanasystems governance REST API.
|
|
438
|
+
*
|
|
439
|
+
* All request and response types are derived directly from the generated
|
|
440
|
+
* `openapi.d.ts` spec, so they stay in sync with the server automatically.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* const client = new ParmanaClient({ baseUrl: "http://localhost:3000", apiKey: "secret" });
|
|
445
|
+
*
|
|
446
|
+
* const attestation = await client.execute({
|
|
447
|
+
* policy_id: "access-control",
|
|
448
|
+
* policy_version: "v1",
|
|
449
|
+
* decision_type: "approve",
|
|
450
|
+
* signals_hash: "abc123...",
|
|
451
|
+
* });
|
|
452
|
+
*
|
|
453
|
+
* const result = await client.verify(attestation);
|
|
454
|
+
* console.log(result.valid); // true
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare class ParmanaClient {
|
|
458
|
+
private readonly baseUrl;
|
|
459
|
+
private readonly defaultHeaders;
|
|
460
|
+
/** @param options - Client configuration including the server URL and optional API key. */
|
|
461
|
+
constructor(options: ParmanaClientOptions);
|
|
462
|
+
private request;
|
|
463
|
+
/** GET /health — returns runtime status and version. */
|
|
464
|
+
health(): Promise<HealthResponse>;
|
|
465
|
+
/**
|
|
466
|
+
* POST /execute — runs the deterministic governance runtime and returns
|
|
467
|
+
* a signed ExecutionAttestation. The returned value can be passed
|
|
468
|
+
* directly to verify().
|
|
469
|
+
*/
|
|
470
|
+
execute(request: ExecuteRequest): Promise<ExecutionAttestation>;
|
|
471
|
+
/**
|
|
472
|
+
* POST /verify — independently verifies an ExecutionAttestation.
|
|
473
|
+
* Pass the object returned by execute() straight into this method.
|
|
474
|
+
*/
|
|
475
|
+
verify(attestation: ExecutionAttestation): Promise<VerificationResult>;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export { type ApiErrorBody, type ExecuteRequest, type ExecutionAttestation, type ExecutionResult, type HealthResponse, ParmanaApiError, ParmanaClient, type ParmanaClientOptions, type VerificationResult };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var ParmanaApiError = class extends Error {
|
|
3
|
+
/** HTTP status code returned by the server. */
|
|
4
|
+
status;
|
|
5
|
+
constructor(status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ParmanaApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var ParmanaClient = class {
|
|
12
|
+
baseUrl;
|
|
13
|
+
defaultHeaders;
|
|
14
|
+
/** @param options - Client configuration including the server URL and optional API key. */
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
17
|
+
this.defaultHeaders = {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
"Accept": "application/json",
|
|
20
|
+
...options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async request(path, init) {
|
|
24
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
25
|
+
...init,
|
|
26
|
+
headers: {
|
|
27
|
+
...this.defaultHeaders,
|
|
28
|
+
...init?.headers ?? {}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const body = await res.json();
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const message = body !== null && typeof body === "object" && "error" in body && typeof body.error === "string" ? body.error : res.statusText;
|
|
34
|
+
throw new ParmanaApiError(res.status, message);
|
|
35
|
+
}
|
|
36
|
+
return body;
|
|
37
|
+
}
|
|
38
|
+
/** GET /health — returns runtime status and version. */
|
|
39
|
+
async health() {
|
|
40
|
+
return this.request("/health");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* POST /execute — runs the deterministic governance runtime and returns
|
|
44
|
+
* a signed ExecutionAttestation. The returned value can be passed
|
|
45
|
+
* directly to verify().
|
|
46
|
+
*/
|
|
47
|
+
async execute(request) {
|
|
48
|
+
return this.request("/execute", {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify(request)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* POST /verify — independently verifies an ExecutionAttestation.
|
|
55
|
+
* Pass the object returned by execute() straight into this method.
|
|
56
|
+
*/
|
|
57
|
+
async verify(attestation) {
|
|
58
|
+
return this.request("/verify", {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: JSON.stringify(attestation)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
ParmanaApiError,
|
|
66
|
+
ParmanaClient
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parmanasystems/sdk-client",
|
|
3
|
+
"version": "1.0.19",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Type-safe SDK client for the parmanasystems Runtime API.",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup",
|
|
9
|
+
"generate": "openapi-typescript ../../openapi.json -o src/openapi.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"openapi-typescript": "^7.13.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
},
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/pavancharak/parmanasystems-core.git"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/pavancharak/parmanasystems-core",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/pavancharak/parmanasystems-core/issues"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"sdk",
|
|
39
|
+
"client",
|
|
40
|
+
"governance",
|
|
41
|
+
"attestation",
|
|
42
|
+
"deterministic"
|
|
43
|
+
],
|
|
44
|
+
"main": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts"
|
|
46
|
+
}
|