@heossi/qnsi 0.3.4 → 0.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/CHANGELOG.md +1 -1
- package/README.md +8 -8
- package/dist/_internal.d.ts +4 -4
- package/dist/_internal.js +7 -7
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +26 -2
- package/dist/audit.js.map +1 -1
- package/dist/autogen/executor.d.ts +5 -5
- package/dist/autogen/executor.js +4 -4
- package/dist/autogen/index.d.ts +4 -4
- package/dist/autogen/index.js +3 -3
- package/dist/browser/sdk-package-version.d.ts +1 -1
- package/dist/browser/sdk-package-version.js +1 -1
- package/dist/client.d.ts +4 -4
- package/dist/client.js +1 -1
- package/dist/errors.d.ts +5 -5
- package/dist/errors.js +10 -10
- package/dist/index.d.ts +23 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/kms.js +4 -4
- package/dist/langchain/index.d.ts +9 -9
- package/dist/langchain/index.js +6 -6
- package/dist/langchain/toolkit.d.ts +5 -5
- package/dist/langchain/toolkit.js +11 -11
- package/dist/langchain/tools/audit.d.ts +3 -3
- package/dist/langchain/tools/audit.js +1 -1
- package/dist/langchain/tools/kms.d.ts +5 -5
- package/dist/langchain/tools/kms.js +2 -2
- package/dist/langchain/tools/vault.d.ts +3 -3
- package/dist/langchain/tools/vault.js +3 -3
- package/dist/langchain/vault-client.d.ts +1 -1
- package/dist/langchain/vault-client.js +1 -1
- package/dist/llamaindex/index.d.ts +4 -4
- package/dist/llamaindex/index.js +3 -3
- package/dist/llamaindex/vector-store.d.ts +5 -5
- package/dist/llamaindex/vector-store.js +4 -4
- package/dist/storage.d.ts +1 -1
- package/dist/storage.js +3 -3
- package/dist/webhooks.d.ts +5 -5
- package/dist/webhooks.js +15 -15
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -43,7 +43,7 @@ The previous TypeScript SDK family was fragmented across 11 packages (`@heossi/q
|
|
|
43
43
|
|
|
44
44
|
### Added
|
|
45
45
|
|
|
46
|
-
- `
|
|
46
|
+
- `QnsiClient({ apiKey, baseUrl?, timeoutMs? })` — top-level client. Lazily activates against `/billing/v1/sdk/activate` on first request, reports `sdkId="qnsp"` and `sdkVersion="0.1.0"`.
|
|
47
47
|
- Eleven service sub-clients sharing one HTTP pool + one activation cache:
|
|
48
48
|
- `qnsp.vault` (createSecret / getSecret / getSecretVersion / rotateSecret / deleteSecret / listSecretVersions)
|
|
49
49
|
- `qnsp.kms` (createKey / listKeys / getKey / rotateKey / deleteKey / sign / verify / wrap / unwrap)
|
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ The official **single-package** Node.js / TypeScript SDK for QNSI. Covers the fu
|
|
|
12
12
|
Previous TypeScript consumers had to install up to 11 separate `@heossi/qnsi-*-sdk` packages and keep their versions in sync. `@heossi/qnsi` collapses that into a single dependency with sub-namespaces:
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
import {
|
|
15
|
+
import { QnsiClient } from "@heossi/qnsi";
|
|
16
16
|
|
|
17
|
-
const qnsp = new
|
|
17
|
+
const qnsp = new QnsiClient({ apiKey: process.env.QNSP_API_KEY! });
|
|
18
18
|
|
|
19
19
|
await qnsp.vault.createSecret({ ... }); // was @heossi/qnsi-vault-sdk
|
|
20
20
|
await qnsp.kms.sign(keyId, data); // was @heossi/qnsi-kms-client
|
|
@@ -40,9 +40,9 @@ Requires Node.js ≥ 22.0.0. ESM-first; CommonJS consumers can `await import("@h
|
|
|
40
40
|
## Quick start
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import {
|
|
43
|
+
import { QnsiClient } from "@heossi/qnsi";
|
|
44
44
|
|
|
45
|
-
const qnsp = new
|
|
45
|
+
const qnsp = new QnsiClient({ apiKey: process.env.QNSP_API_KEY! });
|
|
46
46
|
|
|
47
47
|
// Vault — PQC-encrypted secret storage
|
|
48
48
|
const secret = await qnsp.vault.createSecret({
|
|
@@ -142,7 +142,7 @@ try {
|
|
|
142
142
|
|
|
143
143
|
## Activation + tier introspection
|
|
144
144
|
|
|
145
|
-
`
|
|
145
|
+
`QnsiClient` performs a one-shot handshake against `/billing/v1/sdk/activate` on first use. The result is cached in memory; subsequent calls reuse it until ~60 s before expiry. You can inspect the current activation:
|
|
146
146
|
|
|
147
147
|
```ts
|
|
148
148
|
await qnsp.tenantId(); // resolved tenant
|
|
@@ -162,7 +162,7 @@ The per-service `@heossi/qnsi-*-sdk` packages on npm are now **deprecated** in f
|
|
|
162
162
|
|
|
163
163
|
| Before | After |
|
|
164
164
|
|---|---|
|
|
165
|
-
| `import { VaultClient } from "@heossi/qnsi-vault-sdk"` | `import {
|
|
165
|
+
| `import { VaultClient } from "@heossi/qnsi-vault-sdk"` | `import { QnsiClient } from "@heossi/qnsi"` then `qnsp.vault` |
|
|
166
166
|
| `import { KmsClient } from "@heossi/qnsi-kms-client"` | `qnsp.kms` |
|
|
167
167
|
| `import { AuthClient } from "@heossi/qnsi-auth-sdk"` | `qnsp.auth` |
|
|
168
168
|
| `import { TenantClient } from "@heossi/qnsi-tenant-sdk"` | `qnsp.tenant` |
|
|
@@ -187,9 +187,9 @@ const kms = new KmsClient({ apiKey, baseUrl: "https://api.qnsi.heossi.com/pr
|
|
|
187
187
|
const audit = new AuditClient({ apiKey, baseUrl: "https://api.qnsi.heossi.com/proxy/audit", tier });
|
|
188
188
|
|
|
189
189
|
// After — one package, one activation, one client
|
|
190
|
-
import {
|
|
190
|
+
import { QnsiClient } from "@heossi/qnsi";
|
|
191
191
|
|
|
192
|
-
const qnsp = new
|
|
192
|
+
const qnsp = new QnsiClient({ apiKey });
|
|
193
193
|
// qnsp.vault, qnsp.kms, qnsp.audit, ... all share one connection pool + one activation cache
|
|
194
194
|
```
|
|
195
195
|
|
package/dist/_internal.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared HTTP plumbing + activation cache.
|
|
3
3
|
*
|
|
4
|
-
* Internal — consumers should reach this only via `
|
|
4
|
+
* Internal — consumers should reach this only via `QnsiClient`. Each
|
|
5
5
|
* service module (vault, kms, audit, …) takes an `Internal` instance
|
|
6
6
|
* in its constructor and calls `internal.request(method, path, …)`.
|
|
7
7
|
*/
|
|
8
8
|
import { type SdkActivationResponse } from "./_activation/index.js";
|
|
9
9
|
export declare const SDK_ID = "qnsp";
|
|
10
10
|
export declare const SDK_VERSION = "0.3.0";
|
|
11
|
-
/** Public configuration accepted by `new
|
|
12
|
-
export interface
|
|
11
|
+
/** Public configuration accepted by `new QnsiClient(opts)`. */
|
|
12
|
+
export interface QnsiClientOptions {
|
|
13
13
|
/** API key issued from <https://cloud.qnsi.heossi.com/api-keys>. Required. */
|
|
14
14
|
readonly apiKey: string;
|
|
15
15
|
/** Override the QNSP edge-gateway URL. Defaults to https://api.qnsi.heossi.com. */
|
|
@@ -28,7 +28,7 @@ export declare class Internal {
|
|
|
28
28
|
readonly apiKey: string;
|
|
29
29
|
private cached;
|
|
30
30
|
private activationPromise;
|
|
31
|
-
constructor(opts:
|
|
31
|
+
constructor(opts: QnsiClientOptions);
|
|
32
32
|
/** Force the activation handshake to run now. */
|
|
33
33
|
ensureActivated(): Promise<SdkActivationResponse>;
|
|
34
34
|
/** The activated tenant id (for endpoints that require the tenant in the URL path). */
|
package/dist/_internal.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared HTTP plumbing + activation cache.
|
|
3
3
|
*
|
|
4
|
-
* Internal — consumers should reach this only via `
|
|
4
|
+
* Internal — consumers should reach this only via `QnsiClient`. Each
|
|
5
5
|
* service module (vault, kms, audit, …) takes an `Internal` instance
|
|
6
6
|
* in its constructor and calls `internal.request(method, path, …)`.
|
|
7
7
|
*/
|
|
8
8
|
import { activateSdk } from "./_activation/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { QnsiApiError, QnsiAuthError, QnsiNetworkError } from "./errors.js";
|
|
10
10
|
export const SDK_ID = "qnsp";
|
|
11
|
-
// Bump in lockstep with packages/
|
|
11
|
+
// Bump in lockstep with packages/qnsi/package.json `version` (activation
|
|
12
12
|
// telemetry label). Same release contract as browser/sdk-package-version.ts.
|
|
13
13
|
export const SDK_VERSION = "0.3.0";
|
|
14
14
|
const DEFAULT_BASE_URL = "https://api.qnsi.heossi.com";
|
|
@@ -22,7 +22,7 @@ export class Internal {
|
|
|
22
22
|
activationPromise = null;
|
|
23
23
|
constructor(opts) {
|
|
24
24
|
if (!opts.apiKey || opts.apiKey.trim().length === 0) {
|
|
25
|
-
throw new
|
|
25
|
+
throw new QnsiAuthError("api key required (sign up at https://cloud.qnsi.heossi.com/auth)");
|
|
26
26
|
}
|
|
27
27
|
this.apiKey = opts.apiKey;
|
|
28
28
|
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
@@ -107,7 +107,7 @@ export class Internal {
|
|
|
107
107
|
return JSON.parse(text);
|
|
108
108
|
}
|
|
109
109
|
catch {
|
|
110
|
-
throw new
|
|
110
|
+
throw new QnsiApiError("response is not valid JSON", response.status);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
async send(method, path, body, options) {
|
|
@@ -131,7 +131,7 @@ export class Internal {
|
|
|
131
131
|
return await fetch(url, init);
|
|
132
132
|
}
|
|
133
133
|
catch (err) {
|
|
134
|
-
throw new
|
|
134
|
+
throw new QnsiNetworkError(method, url, err);
|
|
135
135
|
}
|
|
136
136
|
finally {
|
|
137
137
|
clearTimeout(timer);
|
|
@@ -218,7 +218,7 @@ function parseApiError(status, raw) {
|
|
|
218
218
|
else if (typeof raw === "string" && raw.length > 0) {
|
|
219
219
|
message = raw;
|
|
220
220
|
}
|
|
221
|
-
return new
|
|
221
|
+
return new QnsiApiError(message, status, code, body);
|
|
222
222
|
}
|
|
223
223
|
function parseExpiresAt(response) {
|
|
224
224
|
const { expiresAt } = response;
|
package/dist/audit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AA+BD,qBAAa,WAAW;IACX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAE/C,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC;IAI5E,YAAY,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC;IAS9F,UAAU,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC;CAG1C"}
|
package/dist/audit.js
CHANGED
|
@@ -3,16 +3,40 @@
|
|
|
3
3
|
* `apps/audit-service` (`/audit/v1`).
|
|
4
4
|
*/
|
|
5
5
|
const PATH_PREFIX = "/proxy/audit/v1";
|
|
6
|
+
/**
|
|
7
|
+
* Translate the ergonomic SDK event into the wire shape the audit-service
|
|
8
|
+
* actually accepts. This is the contract-translation boundary — callers keep
|
|
9
|
+
* passing `{ eventType, payload, tags }` unchanged.
|
|
10
|
+
*
|
|
11
|
+
* `normalizeBatch` (`apps/audit-service/src/services/audit-service.ts`) matches
|
|
12
|
+
* one of three strict schemas. The `_internal` client injects a top-level
|
|
13
|
+
* `tenantId` into every body, which **fails** the `legacyAttestation` schema
|
|
14
|
+
* (`{ eventType, timestamp?, severity?, payload? }`, `.strict()` → rejects
|
|
15
|
+
* `tenantId` → 0 events → HTTP 400). The only path that tolerates the injected
|
|
16
|
+
* `tenantId` is `legacySecurityAuditClientEventSchema`, which carries
|
|
17
|
+
* `{ eventType?, source?, tenantId?, details?, … }` and maps `details` → the
|
|
18
|
+
* stored event `payload` (and honours `tenantId` for tenant-scoping). So the
|
|
19
|
+
* caller's `payload` goes into `details`, and `tags` rides alongside as
|
|
20
|
+
* `details.tags`. Verified live: `{tenantId,eventType,source,details}` → 202;
|
|
21
|
+
* `{tenantId,eventType,payload}` → 400.
|
|
22
|
+
*/
|
|
23
|
+
function toWireEvent(req) {
|
|
24
|
+
const details = { ...req.payload };
|
|
25
|
+
if (req.tags && req.tags.length > 0) {
|
|
26
|
+
details["tags"] = [...req.tags];
|
|
27
|
+
}
|
|
28
|
+
return { eventType: req.eventType, source: "qnsi-sdk", details };
|
|
29
|
+
}
|
|
6
30
|
export class AuditClient {
|
|
7
31
|
internal;
|
|
8
32
|
constructor(internal) {
|
|
9
33
|
this.internal = internal;
|
|
10
34
|
}
|
|
11
35
|
logEvent(req, opts) {
|
|
12
|
-
return this.internal.request("POST", `${PATH_PREFIX}/events`, req, opts);
|
|
36
|
+
return this.internal.request("POST", `${PATH_PREFIX}/events`, toWireEvent(req), opts);
|
|
13
37
|
}
|
|
14
38
|
ingestEvents(events, opts) {
|
|
15
|
-
return this.internal.request("POST", `${PATH_PREFIX}/events/batch`, { events }, opts);
|
|
39
|
+
return this.internal.request("POST", `${PATH_PREFIX}/events/batch`, { events: events.map(toWireEvent) }, opts);
|
|
16
40
|
}
|
|
17
41
|
listEvents(query) {
|
|
18
42
|
return this.internal.request("GET", `${PATH_PREFIX}/events`, undefined, { query });
|
package/dist/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAQtC,MAAM,OAAO,WAAW;IACM;IAA7B,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEnD,QAAQ,CAAC,GAAoB,EAAE,IAA6C;QAC3E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,WAAW,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAQtC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,WAAW,CAAC,GAAoB;IAKxC,MAAM,OAAO,GAA4B,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5D,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAClE,CAAC;AAED,MAAM,OAAO,WAAW;IACM;IAA7B,YAA6B,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEnD,QAAQ,CAAC,GAAoB,EAAE,IAA6C;QAC3E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,WAAW,SAAS,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACvF,CAAC;IAED,YAAY,CAAC,MAAkC,EAAE,IAA6C;QAC7F,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC3B,MAAM,EACN,GAAG,WAAW,eAAe,EAC7B,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EACnC,IAAI,CACJ,CAAC;IACH,CAAC;IAED,UAAU,CAAC,KAA+B;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,WAAW,SAAS,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;CACD"}
|
|
@@ -86,7 +86,7 @@ export interface WorkloadDetail extends WorkloadSummary {
|
|
|
86
86
|
readonly artifacts: readonly WorkloadArtifactBinding[];
|
|
87
87
|
readonly schedulerMetadata: Record<string, unknown> | null;
|
|
88
88
|
}
|
|
89
|
-
export interface
|
|
89
|
+
export interface QnsiExecutorConfig {
|
|
90
90
|
/**
|
|
91
91
|
* QNSP API key. Get one at https://cloud.qnsi.heossi.com/api-keys
|
|
92
92
|
* The API key carries the tenant ID — no separate tenantId needed.
|
|
@@ -182,16 +182,16 @@ export interface ExecuteCodeResult {
|
|
|
182
182
|
*
|
|
183
183
|
* @example
|
|
184
184
|
* ```typescript
|
|
185
|
-
* import {
|
|
185
|
+
* import { QnsiExecutor } from "@heossi/qnsi/autogen";
|
|
186
186
|
*
|
|
187
|
-
* const executor = new
|
|
187
|
+
* const executor = new QnsiExecutor({ apiKey: process.env.QNSP_API_KEY });
|
|
188
188
|
* const result = await executor.execute({ code: "print('hi')", language: "python" });
|
|
189
189
|
* console.log(result.status, result.attestationProof);
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
export declare class
|
|
192
|
+
export declare class QnsiExecutor {
|
|
193
193
|
#private;
|
|
194
|
-
constructor(config:
|
|
194
|
+
constructor(config: QnsiExecutorConfig);
|
|
195
195
|
/**
|
|
196
196
|
* Execute code inside a QNSP enclave and wait for the result.
|
|
197
197
|
*/
|
package/dist/autogen/executor.js
CHANGED
|
@@ -47,20 +47,20 @@ const LANGUAGE_COMMANDS = {
|
|
|
47
47
|
bash: ["bash", "-c"],
|
|
48
48
|
javascript: ["node", "-e"],
|
|
49
49
|
};
|
|
50
|
-
// ───
|
|
50
|
+
// ─── QnsiExecutor ─────────────────────────────────────────────────────────────
|
|
51
51
|
/**
|
|
52
52
|
* AutoGen-compatible code executor backed by QNSP AI orchestrator enclaves.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```typescript
|
|
56
|
-
* import {
|
|
56
|
+
* import { QnsiExecutor } from "@heossi/qnsi/autogen";
|
|
57
57
|
*
|
|
58
|
-
* const executor = new
|
|
58
|
+
* const executor = new QnsiExecutor({ apiKey: process.env.QNSP_API_KEY });
|
|
59
59
|
* const result = await executor.execute({ code: "print('hi')", language: "python" });
|
|
60
60
|
* console.log(result.status, result.attestationProof);
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
export class
|
|
63
|
+
export class QnsiExecutor {
|
|
64
64
|
#apiKey;
|
|
65
65
|
#baseUrl;
|
|
66
66
|
#containerImage;
|
package/dist/autogen/index.d.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import {
|
|
10
|
+
* import { QnsiExecutor } from "@heossi/qnsi/autogen";
|
|
11
11
|
*
|
|
12
|
-
* const executor = new
|
|
12
|
+
* const executor = new QnsiExecutor({ apiKey: process.env.QNSP_API_KEY });
|
|
13
13
|
* const result = await executor.execute({ code: "print('Hello')", language: "python" });
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export type { ExecuteCodeRequest, ExecuteCodeResult,
|
|
17
|
-
export {
|
|
16
|
+
export type { ExecuteCodeRequest, ExecuteCodeResult, QnsiExecutorConfig, SubmitWorkloadRequest, WorkloadDetail, WorkloadStatus, } from "./executor.js";
|
|
17
|
+
export { QnsiExecutor } from "./executor.js";
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/autogen/index.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import {
|
|
10
|
+
* import { QnsiExecutor } from "@heossi/qnsi/autogen";
|
|
11
11
|
*
|
|
12
|
-
* const executor = new
|
|
12
|
+
* const executor = new QnsiExecutor({ apiKey: process.env.QNSP_API_KEY });
|
|
13
13
|
* const result = await executor.execute({ code: "print('Hello')", language: "python" });
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export {
|
|
16
|
+
export { QnsiExecutor } from "./executor.js";
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* must stay browser-safe — no `node:fs` runtime read — and a static JSON
|
|
7
7
|
* import would resolve outside the package `rootDir` (TS6059). This mirrors
|
|
8
8
|
* the same release-bump contract as `SDK_VERSION` in `../_internal.ts`:
|
|
9
|
-
* **bump this in lockstep with `packages/
|
|
9
|
+
* **bump this in lockstep with `packages/qnsi/package.json` `version`.**
|
|
10
10
|
*/
|
|
11
11
|
export declare const SDK_PACKAGE_VERSION = "0.3.0";
|
|
12
12
|
//# sourceMappingURL=sdk-package-version.d.ts.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* must stay browser-safe — no `node:fs` runtime read — and a static JSON
|
|
7
7
|
* import would resolve outside the package `rootDir` (TS6059). This mirrors
|
|
8
8
|
* the same release-bump contract as `SDK_VERSION` in `../_internal.ts`:
|
|
9
|
-
* **bump this in lockstep with `packages/
|
|
9
|
+
* **bump this in lockstep with `packages/qnsi/package.json` `version`.**
|
|
10
10
|
*/
|
|
11
11
|
export const SDK_PACKAGE_VERSION = "0.3.0";
|
|
12
12
|
//# sourceMappingURL=sdk-package-version.js.map
|
package/dist/client.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* SDK shape byte-for-byte.
|
|
9
9
|
*/
|
|
10
10
|
import type { SdkActivationResponse } from "./_activation/index.js";
|
|
11
|
-
import { type
|
|
11
|
+
import { type QnsiClientOptions } from "./_internal.js";
|
|
12
12
|
import { AccessClient } from "./access.js";
|
|
13
13
|
import { AiClient } from "./ai.js";
|
|
14
14
|
import { AuditClient } from "./audit.js";
|
|
@@ -20,7 +20,7 @@ import { SearchClient } from "./search.js";
|
|
|
20
20
|
import { StorageClient } from "./storage.js";
|
|
21
21
|
import { TenantClient } from "./tenant.js";
|
|
22
22
|
import { VaultClient } from "./vault.js";
|
|
23
|
-
export declare class
|
|
23
|
+
export declare class QnsiClient {
|
|
24
24
|
readonly vault: VaultClient;
|
|
25
25
|
readonly kms: KmsClient;
|
|
26
26
|
readonly audit: AuditClient;
|
|
@@ -33,7 +33,7 @@ export declare class QnspClient {
|
|
|
33
33
|
readonly search: SearchClient;
|
|
34
34
|
readonly ai: AiClient;
|
|
35
35
|
private readonly internal;
|
|
36
|
-
constructor(options:
|
|
36
|
+
constructor(options: QnsiClientOptions);
|
|
37
37
|
/**
|
|
38
38
|
* Force the activation handshake to run now. Surfaces invalid-API-key
|
|
39
39
|
* errors at startup rather than on the first service call.
|
|
@@ -48,5 +48,5 @@ export declare class QnspClient {
|
|
|
48
48
|
/** Whether the tenant's plan enables a billing-side boolean feature. */
|
|
49
49
|
hasFeature(feature: string): Promise<boolean>;
|
|
50
50
|
}
|
|
51
|
-
export type {
|
|
51
|
+
export type { QnsiClientOptions } from "./_internal.js";
|
|
52
52
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
CHANGED
|
@@ -19,7 +19,7 @@ import { SearchClient } from "./search.js";
|
|
|
19
19
|
import { StorageClient } from "./storage.js";
|
|
20
20
|
import { TenantClient } from "./tenant.js";
|
|
21
21
|
import { VaultClient } from "./vault.js";
|
|
22
|
-
export class
|
|
22
|
+
export class QnsiClient {
|
|
23
23
|
vault;
|
|
24
24
|
kms;
|
|
25
25
|
audit;
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,29 +6,29 @@
|
|
|
6
6
|
* the failure mode without parsing error messages.
|
|
7
7
|
*/
|
|
8
8
|
/** Base class — all QNSP SDK errors inherit. */
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class QnsiError extends Error {
|
|
10
10
|
constructor(message: string, options?: ErrorOptions);
|
|
11
11
|
}
|
|
12
12
|
/** DNS, TLS, timeout, or connection failure reaching the QNSP edge gateway. */
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class QnsiNetworkError extends QnsiError {
|
|
14
14
|
readonly op: string;
|
|
15
15
|
readonly url: string;
|
|
16
16
|
constructor(op: string, url: string, cause?: unknown);
|
|
17
17
|
}
|
|
18
18
|
/** API key rejected at activation. */
|
|
19
|
-
export declare class
|
|
19
|
+
export declare class QnsiAuthError extends QnsiError {
|
|
20
20
|
readonly code: string | null;
|
|
21
21
|
constructor(message: string, code?: string | null);
|
|
22
22
|
}
|
|
23
23
|
/** A QNSP service returned a 4xx/5xx with a structured body. */
|
|
24
|
-
export declare class
|
|
24
|
+
export declare class QnsiApiError extends QnsiError {
|
|
25
25
|
readonly statusCode: number;
|
|
26
26
|
readonly code: string | null;
|
|
27
27
|
readonly body: unknown;
|
|
28
28
|
constructor(message: string, statusCode: number, code?: string | null, body?: unknown);
|
|
29
29
|
}
|
|
30
30
|
/** HMAC mismatch, expired/future timestamp, malformed body, or missing fields. */
|
|
31
|
-
export declare class
|
|
31
|
+
export declare class QnsiWebhookError extends QnsiError {
|
|
32
32
|
readonly reason: string;
|
|
33
33
|
constructor(reason: string);
|
|
34
34
|
}
|
package/dist/errors.js
CHANGED
|
@@ -6,51 +6,51 @@
|
|
|
6
6
|
* the failure mode without parsing error messages.
|
|
7
7
|
*/
|
|
8
8
|
/** Base class — all QNSP SDK errors inherit. */
|
|
9
|
-
export class
|
|
9
|
+
export class QnsiError extends Error {
|
|
10
10
|
constructor(message, options) {
|
|
11
11
|
super(message, options);
|
|
12
|
-
this.name = "
|
|
12
|
+
this.name = "QnsiError";
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
/** DNS, TLS, timeout, or connection failure reaching the QNSP edge gateway. */
|
|
16
|
-
export class
|
|
16
|
+
export class QnsiNetworkError extends QnsiError {
|
|
17
17
|
op;
|
|
18
18
|
url;
|
|
19
19
|
constructor(op, url, cause) {
|
|
20
20
|
super(`qnsp: network error on ${op} ${url}: ${stringifyCause(cause)}`, { cause });
|
|
21
|
-
this.name = "
|
|
21
|
+
this.name = "QnsiNetworkError";
|
|
22
22
|
this.op = op;
|
|
23
23
|
this.url = url;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
/** API key rejected at activation. */
|
|
27
|
-
export class
|
|
27
|
+
export class QnsiAuthError extends QnsiError {
|
|
28
28
|
code;
|
|
29
29
|
constructor(message, code = null) {
|
|
30
30
|
super(`qnsp: auth error${code ? ` (${code})` : ""}: ${message}`);
|
|
31
|
-
this.name = "
|
|
31
|
+
this.name = "QnsiAuthError";
|
|
32
32
|
this.code = code;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
/** A QNSP service returned a 4xx/5xx with a structured body. */
|
|
36
|
-
export class
|
|
36
|
+
export class QnsiApiError extends QnsiError {
|
|
37
37
|
statusCode;
|
|
38
38
|
code;
|
|
39
39
|
body;
|
|
40
40
|
constructor(message, statusCode, code = null, body = null) {
|
|
41
41
|
super(`qnsp: api error ${statusCode}${code ? ` ${code}` : ""}: ${message}`);
|
|
42
|
-
this.name = "
|
|
42
|
+
this.name = "QnsiApiError";
|
|
43
43
|
this.statusCode = statusCode;
|
|
44
44
|
this.code = code;
|
|
45
45
|
this.body = body;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/** HMAC mismatch, expired/future timestamp, malformed body, or missing fields. */
|
|
49
|
-
export class
|
|
49
|
+
export class QnsiWebhookError extends QnsiError {
|
|
50
50
|
reason;
|
|
51
51
|
constructor(reason) {
|
|
52
52
|
super(`qnsp: webhook error: ${reason}`);
|
|
53
|
-
this.name = "
|
|
53
|
+
this.name = "QnsiWebhookError";
|
|
54
54
|
this.reason = reason;
|
|
55
55
|
}
|
|
56
56
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,13 +38,33 @@ export { AiClient, type InferenceRequest, type RegisterArtifactRequest, type Reg
|
|
|
38
38
|
export { AuditClient, type LogEventRequest } from "./audit.js";
|
|
39
39
|
export { AuthClient, type LoginRequest } from "./auth.js";
|
|
40
40
|
export { BillingClient, type IngestMeterRequest } from "./billing.js";
|
|
41
|
-
export {
|
|
41
|
+
export { QnsiClient,
|
|
42
|
+
/** @deprecated Use `QnsiClient`. Kept for pre-rebrand consumers. */
|
|
43
|
+
QnsiClient as QnspClient, type QnsiClientOptions,
|
|
44
|
+
/** @deprecated Use `QnsiClientOptions`. */
|
|
45
|
+
type QnsiClientOptions as QnspClientOptions, } from "./client.js";
|
|
42
46
|
export { CryptoInventoryClient, type DiscoverAssetsRequest } from "./crypto-inventory.js";
|
|
43
|
-
export {
|
|
47
|
+
export { QnsiApiError,
|
|
48
|
+
/** @deprecated Use `QnsiApiError`. */
|
|
49
|
+
QnsiApiError as QnspApiError, QnsiAuthError,
|
|
50
|
+
/** @deprecated Use `QnsiAuthError`. */
|
|
51
|
+
QnsiAuthError as QnspAuthError, QnsiError,
|
|
52
|
+
/** @deprecated Use `QnsiError`. */
|
|
53
|
+
QnsiError as QnspError, QnsiNetworkError,
|
|
54
|
+
/** @deprecated Use `QnsiNetworkError`. */
|
|
55
|
+
QnsiNetworkError as QnspNetworkError, QnsiWebhookError,
|
|
56
|
+
/** @deprecated Use `QnsiWebhookError`. */
|
|
57
|
+
QnsiWebhookError as QnspWebhookError, } from "./errors.js";
|
|
44
58
|
export { type CreateKeyRequest, KmsClient } from "./kms.js";
|
|
45
59
|
export { type CreateIndexRequest, type QueryRequest, SearchClient, type Vector, } from "./search.js";
|
|
46
60
|
export { type PutObjectInput, StorageClient } from "./storage.js";
|
|
47
61
|
export { type CreateTenantRequest, TenantClient } from "./tenant.js";
|
|
48
62
|
export { type CreateSecretRequest, VaultClient } from "./vault.js";
|
|
49
|
-
export { MAX_WEBHOOK_SKEW_MS,
|
|
63
|
+
export { MAX_WEBHOOK_SKEW_MS, parseQnsiWebhook,
|
|
64
|
+
/** @deprecated Use `parseQnsiWebhook`. */
|
|
65
|
+
parseQnsiWebhook as parseQnspWebhook, type QnsiWebhookEvent,
|
|
66
|
+
/** @deprecated Use `QnsiWebhookEvent`. */
|
|
67
|
+
type QnsiWebhookEvent as QnspWebhookEvent, verifyQnsiWebhookSignature,
|
|
68
|
+
/** @deprecated Use `verifyQnsiWebhookSignature`. */
|
|
69
|
+
verifyQnsiWebhookSignature as verifyQnspWebhookSignature, } from "./webhooks.js";
|
|
50
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGtE,OAAO,EACN,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACN,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGtE,OAAO,EACN,UAAU;AACV,oEAAoE;AACpE,UAAU,IAAI,UAAU,EACxB,KAAK,iBAAiB;AACtB,2CAA2C;AAC3C,KAAK,iBAAiB,IAAI,iBAAiB,GAC3C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACN,YAAY;AACZ,sCAAsC;AACtC,YAAY,IAAI,YAAY,EAC5B,aAAa;AACb,uCAAuC;AACvC,aAAa,IAAI,aAAa,EAC9B,SAAS;AACT,mCAAmC;AACnC,SAAS,IAAI,SAAS,EACtB,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,EACpC,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,GACpC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,YAAY,EACZ,KAAK,MAAM,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,KAAK,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,KAAK,mBAAmB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACN,mBAAmB,EACnB,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,EACpC,KAAK,gBAAgB;AACrB,0CAA0C;AAC1C,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,0BAA0B;AAC1B,oDAAoD;AACpD,0BAA0B,IAAI,0BAA0B,GACxD,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -39,15 +39,31 @@ export { AuditClient } from "./audit.js";
|
|
|
39
39
|
export { AuthClient } from "./auth.js";
|
|
40
40
|
export { BillingClient } from "./billing.js";
|
|
41
41
|
// QnsiClient is the canonical name (product is QNSI). QnspClient is kept as a
|
|
42
|
-
// back-compat alias for consumers on the pre-rebrand name.
|
|
43
|
-
export {
|
|
42
|
+
// @deprecated back-compat alias for consumers on the pre-rebrand name.
|
|
43
|
+
export { QnsiClient,
|
|
44
|
+
/** @deprecated Use `QnsiClient`. Kept for pre-rebrand consumers. */
|
|
45
|
+
QnsiClient as QnspClient, } from "./client.js";
|
|
44
46
|
export { CryptoInventoryClient } from "./crypto-inventory.js";
|
|
45
|
-
export {
|
|
47
|
+
export { QnsiApiError,
|
|
48
|
+
/** @deprecated Use `QnsiApiError`. */
|
|
49
|
+
QnsiApiError as QnspApiError, QnsiAuthError,
|
|
50
|
+
/** @deprecated Use `QnsiAuthError`. */
|
|
51
|
+
QnsiAuthError as QnspAuthError, QnsiError,
|
|
52
|
+
/** @deprecated Use `QnsiError`. */
|
|
53
|
+
QnsiError as QnspError, QnsiNetworkError,
|
|
54
|
+
/** @deprecated Use `QnsiNetworkError`. */
|
|
55
|
+
QnsiNetworkError as QnspNetworkError, QnsiWebhookError,
|
|
56
|
+
/** @deprecated Use `QnsiWebhookError`. */
|
|
57
|
+
QnsiWebhookError as QnspWebhookError, } from "./errors.js";
|
|
46
58
|
export { KmsClient } from "./kms.js";
|
|
47
59
|
export { SearchClient, } from "./search.js";
|
|
48
60
|
export { StorageClient } from "./storage.js";
|
|
49
61
|
export { TenantClient } from "./tenant.js";
|
|
50
62
|
// Service classes — exported so callers can construct mocks for testing.
|
|
51
63
|
export { VaultClient } from "./vault.js";
|
|
52
|
-
export { MAX_WEBHOOK_SKEW_MS,
|
|
64
|
+
export { MAX_WEBHOOK_SKEW_MS, parseQnsiWebhook,
|
|
65
|
+
/** @deprecated Use `parseQnsiWebhook`. */
|
|
66
|
+
parseQnsiWebhook as parseQnspWebhook, verifyQnsiWebhookSignature,
|
|
67
|
+
/** @deprecated Use `verifyQnsiWebhookSignature`. */
|
|
68
|
+
verifyQnsiWebhookSignature as verifyQnspWebhookSignature, } from "./webhooks.js";
|
|
53
69
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACN,YAAY,GAIZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,QAAQ,GAKR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAwB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAA2B,MAAM,cAAc,CAAC;AACtE,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACN,YAAY,GAIZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,QAAQ,GAKR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAwB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAA2B,MAAM,cAAc,CAAC;AACtE,8EAA8E;AAC9E,uEAAuE;AACvE,OAAO,EACN,UAAU;AACV,oEAAoE;AACpE,UAAU,IAAI,UAAU,GAIxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAA8B,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACN,YAAY;AACZ,sCAAsC;AACtC,YAAY,IAAI,YAAY,EAC5B,aAAa;AACb,uCAAuC;AACvC,aAAa,IAAI,aAAa,EAC9B,SAAS;AACT,mCAAmC;AACnC,SAAS,IAAI,SAAS,EACtB,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,EACpC,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,GACpC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAyB,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAGN,YAAY,GAEZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAuB,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAA4B,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,yEAAyE;AACzE,OAAO,EAA4B,WAAW,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACN,mBAAmB,EACnB,gBAAgB;AAChB,0CAA0C;AAC1C,gBAAgB,IAAI,gBAAgB,EAIpC,0BAA0B;AAC1B,oDAAoD;AACpD,0BAA0B,IAAI,0BAA0B,GACxD,MAAM,eAAe,CAAC"}
|
package/dist/kms.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* QNSP KMS — server-side PQC keys with sign, verify, wrap, and unwrap.
|
|
3
3
|
* Wraps `apps/kms-service` (`/kms/v1`).
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { QnsiApiError } from "./errors.js";
|
|
6
6
|
const PATH_PREFIX = "/proxy/kms/v1";
|
|
7
7
|
export class KmsClient {
|
|
8
8
|
internal;
|
|
@@ -45,7 +45,7 @@ export class KmsClient {
|
|
|
45
45
|
const body = { data: encodeB64(data) };
|
|
46
46
|
const resp = await this.internal.request("POST", `${PATH_PREFIX}/keys/${keyId}/sign`, body, opts);
|
|
47
47
|
if (!resp.signature) {
|
|
48
|
-
throw new
|
|
48
|
+
throw new QnsiApiError("kms.sign: response missing signature", 200);
|
|
49
49
|
}
|
|
50
50
|
return decodeB64(resp.signature);
|
|
51
51
|
}
|
|
@@ -65,7 +65,7 @@ export class KmsClient {
|
|
|
65
65
|
const resp = await this.internal.request("POST", `${PATH_PREFIX}/keys/${keyId}/wrap`, body, opts);
|
|
66
66
|
const wrapped = resp.wrappedKey ?? resp.ciphertextB64;
|
|
67
67
|
if (!wrapped) {
|
|
68
|
-
throw new
|
|
68
|
+
throw new QnsiApiError("kms.wrap: response missing wrappedKey/ciphertextB64", 200);
|
|
69
69
|
}
|
|
70
70
|
return decodeB64(wrapped);
|
|
71
71
|
}
|
|
@@ -78,7 +78,7 @@ export class KmsClient {
|
|
|
78
78
|
const resp = await this.internal.request("POST", `${PATH_PREFIX}/keys/${keyId}/unwrap`, body, opts);
|
|
79
79
|
const unwrapped = resp.dataKey ?? resp.plaintextB64;
|
|
80
80
|
if (!unwrapped) {
|
|
81
|
-
throw new
|
|
81
|
+
throw new QnsiApiError("kms.unwrap: response missing dataKey/plaintextB64", 200);
|
|
82
82
|
}
|
|
83
83
|
return decodeB64(unwrapped);
|
|
84
84
|
}
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {
|
|
9
|
+
* import { QnsiToolkit } from "@heossi/qnsi-langchain-qnsp";
|
|
10
10
|
*
|
|
11
|
-
* const toolkit = new
|
|
11
|
+
* const toolkit = new QnsiToolkit({ apiKey: process.env.QNSP_API_KEY });
|
|
12
12
|
* const tools = toolkit.getTools();
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
-
export type {
|
|
16
|
-
export {
|
|
17
|
-
export type {
|
|
18
|
-
export {
|
|
19
|
-
export type {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
15
|
+
export type { QnsiToolkitConfig } from "./toolkit.js";
|
|
16
|
+
export { QnsiToolkit } from "./toolkit.js";
|
|
17
|
+
export type { QnsiAuditToolConfig } from "./tools/audit.js";
|
|
18
|
+
export { QnsiLogAgentActionTool } from "./tools/audit.js";
|
|
19
|
+
export type { QnsiKmsToolConfig } from "./tools/kms.js";
|
|
20
|
+
export { QnsiSignDataTool, QnsiVerifySignatureTool } from "./tools/kms.js";
|
|
21
|
+
export { QnsiReadSecretTool, QnsiRotateSecretTool, QnsiWriteSecretTool } from "./tools/vault.js";
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/langchain/index.js
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {
|
|
9
|
+
* import { QnsiToolkit } from "@heossi/qnsi-langchain-qnsp";
|
|
10
10
|
*
|
|
11
|
-
* const toolkit = new
|
|
11
|
+
* const toolkit = new QnsiToolkit({ apiKey: process.env.QNSP_API_KEY });
|
|
12
12
|
* const tools = toolkit.getTools();
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
// Toolkit (recommended entry point)
|
|
16
|
-
export {
|
|
16
|
+
export { QnsiToolkit } from "./toolkit.js";
|
|
17
17
|
// Individual audit tools
|
|
18
|
-
export {
|
|
18
|
+
export { QnsiLogAgentActionTool } from "./tools/audit.js";
|
|
19
19
|
// Individual KMS tools
|
|
20
|
-
export {
|
|
20
|
+
export { QnsiSignDataTool, QnsiVerifySignatureTool } from "./tools/kms.js";
|
|
21
21
|
// Individual vault tools
|
|
22
|
-
export {
|
|
22
|
+
export { QnsiReadSecretTool, QnsiRotateSecretTool, QnsiWriteSecretTool } from "./tools/vault.js";
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import {
|
|
10
|
+
* import { QnsiToolkit } from "@heossi/qnsi-langchain-qnsp";
|
|
11
11
|
* import { ChatOpenAI } from "@langchain/openai";
|
|
12
12
|
* import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
|
|
13
13
|
*
|
|
14
|
-
* const toolkit = new
|
|
14
|
+
* const toolkit = new QnsiToolkit({
|
|
15
15
|
* apiKey: process.env.QNSP_API_KEY,
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
import type { StructuredTool } from "@langchain/core/tools";
|
|
26
|
-
export interface
|
|
26
|
+
export interface QnsiToolkitConfig {
|
|
27
27
|
/**
|
|
28
28
|
* QNSP API key. Get one at https://cloud.qnsi.heossi.com/api-keys
|
|
29
29
|
* The API key carries the tenant ID — no separate tenantId needed.
|
|
@@ -58,9 +58,9 @@ export interface QnspToolkitConfig {
|
|
|
58
58
|
* - KMS tools: sign and verify data with quantum-safe algorithms
|
|
59
59
|
* - Audit tools: write immutable, PQC-signed audit events
|
|
60
60
|
*/
|
|
61
|
-
export declare class
|
|
61
|
+
export declare class QnsiToolkit {
|
|
62
62
|
#private;
|
|
63
|
-
constructor(config:
|
|
63
|
+
constructor(config: QnsiToolkitConfig);
|
|
64
64
|
/**
|
|
65
65
|
* One-shot activation handshake against billing-service. Validates the API
|
|
66
66
|
* key, captures tenantId + tier, caches the activation token. Required:
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
|
-
* import {
|
|
10
|
+
* import { QnsiToolkit } from "@heossi/qnsi-langchain-qnsp";
|
|
11
11
|
* import { ChatOpenAI } from "@langchain/openai";
|
|
12
12
|
* import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
|
|
13
13
|
*
|
|
14
|
-
* const toolkit = new
|
|
14
|
+
* const toolkit = new QnsiToolkit({
|
|
15
15
|
* apiKey: process.env.QNSP_API_KEY,
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
import { activateSdk } from "../_activation/index.js";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
26
|
+
import { QnsiLogAgentActionTool } from "./tools/audit.js";
|
|
27
|
+
import { QnsiSignDataTool, QnsiVerifySignatureTool } from "./tools/kms.js";
|
|
28
|
+
import { QnsiReadSecretTool, QnsiRotateSecretTool, QnsiWriteSecretTool } from "./tools/vault.js";
|
|
29
29
|
import { VaultClient } from "./vault-client.js";
|
|
30
30
|
const SDK_VERSION = "0.3.0";
|
|
31
31
|
/**
|
|
@@ -36,7 +36,7 @@ const SDK_VERSION = "0.3.0";
|
|
|
36
36
|
* - KMS tools: sign and verify data with quantum-safe algorithms
|
|
37
37
|
* - Audit tools: write immutable, PQC-signed audit events
|
|
38
38
|
*/
|
|
39
|
-
export class
|
|
39
|
+
export class QnsiToolkit {
|
|
40
40
|
#apiKey;
|
|
41
41
|
#tenantId;
|
|
42
42
|
#baseUrl;
|
|
@@ -111,9 +111,9 @@ export class QnspToolkit {
|
|
|
111
111
|
getVaultTools() {
|
|
112
112
|
this.#assertActivated();
|
|
113
113
|
return [
|
|
114
|
-
new
|
|
115
|
-
new
|
|
116
|
-
new
|
|
114
|
+
new QnsiReadSecretTool(this.#vaultClient),
|
|
115
|
+
new QnsiWriteSecretTool(this.#vaultClient),
|
|
116
|
+
new QnsiRotateSecretTool(this.#vaultClient),
|
|
117
117
|
];
|
|
118
118
|
}
|
|
119
119
|
/** Returns only the KMS tools (sign, verify). */
|
|
@@ -125,7 +125,7 @@ export class QnspToolkit {
|
|
|
125
125
|
tenantId: this.#tenantId,
|
|
126
126
|
timeoutMs: this.#timeoutMs,
|
|
127
127
|
};
|
|
128
|
-
return [new
|
|
128
|
+
return [new QnsiSignDataTool(kmsConfig), new QnsiVerifySignatureTool(kmsConfig)];
|
|
129
129
|
}
|
|
130
130
|
/** Returns only the audit tool (log agent actions). */
|
|
131
131
|
getAuditTools() {
|
|
@@ -136,7 +136,7 @@ export class QnspToolkit {
|
|
|
136
136
|
tenantId: this.#tenantId,
|
|
137
137
|
timeoutMs: this.#timeoutMs,
|
|
138
138
|
};
|
|
139
|
-
return [new
|
|
139
|
+
return [new QnsiLogAgentActionTool(auditConfig)];
|
|
140
140
|
}
|
|
141
141
|
/** True once `activate()` has resolved successfully. */
|
|
142
142
|
get isActivated() {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { StructuredTool, type ToolParams } from "@langchain/core/tools";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
export interface
|
|
9
|
+
export interface QnsiAuditToolConfig {
|
|
10
10
|
/** Base URL for the QNSP API (e.g. https://api.qnsi.heossi.com) */
|
|
11
11
|
readonly baseUrl: string;
|
|
12
12
|
/** API key or Bearer token for authentication */
|
|
@@ -26,7 +26,7 @@ declare const logAgentActionSchema: z.ZodObject<{
|
|
|
26
26
|
* LangChain tool that writes an immutable, PQC-signed audit event to QNSP.
|
|
27
27
|
* Use this to create a tamper-evident record of every significant agent action.
|
|
28
28
|
*/
|
|
29
|
-
export declare class
|
|
29
|
+
export declare class QnsiLogAgentActionTool extends StructuredTool {
|
|
30
30
|
#private;
|
|
31
31
|
readonly name = "qnsp_log_agent_action";
|
|
32
32
|
readonly description = "Write an immutable, PQC-signed audit event to QNSP. Creates a tamper-evident record of agent actions, decisions, tool calls, and outputs. Use this for compliance, governance, and traceability of agent behavior.";
|
|
@@ -36,7 +36,7 @@ export declare class QnspLogAgentActionTool extends StructuredTool {
|
|
|
36
36
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
37
37
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
38
38
|
}, z.core.$strip>;
|
|
39
|
-
constructor(config:
|
|
39
|
+
constructor(config: QnsiAuditToolConfig, fields?: ToolParams);
|
|
40
40
|
protected _call(input: z.infer<typeof logAgentActionSchema>): Promise<string>;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
@@ -30,7 +30,7 @@ const logAgentActionSchema = z.object({
|
|
|
30
30
|
* LangChain tool that writes an immutable, PQC-signed audit event to QNSP.
|
|
31
31
|
* Use this to create a tamper-evident record of every significant agent action.
|
|
32
32
|
*/
|
|
33
|
-
export class
|
|
33
|
+
export class QnsiLogAgentActionTool extends StructuredTool {
|
|
34
34
|
name = "qnsp_log_agent_action";
|
|
35
35
|
description = "Write an immutable, PQC-signed audit event to QNSP. Creates a tamper-evident record of agent actions, decisions, tool calls, and outputs. Use this for compliance, governance, and traceability of agent behavior.";
|
|
36
36
|
schema = logAgentActionSchema;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { StructuredTool, type ToolParams } from "@langchain/core/tools";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
export interface
|
|
9
|
+
export interface QnsiKmsToolConfig {
|
|
10
10
|
/** Base URL for the QNSP API (e.g. https://api.qnsi.heossi.com) */
|
|
11
11
|
readonly baseUrl: string;
|
|
12
12
|
/** API key or Bearer token for authentication */
|
|
@@ -24,7 +24,7 @@ declare const signDataSchema: z.ZodObject<{
|
|
|
24
24
|
/**
|
|
25
25
|
* LangChain tool that signs data with a PQC key (ML-DSA / SLH-DSA / FN-DSA).
|
|
26
26
|
*/
|
|
27
|
-
export declare class
|
|
27
|
+
export declare class QnsiSignDataTool extends StructuredTool {
|
|
28
28
|
#private;
|
|
29
29
|
readonly name = "qnsp_sign_data";
|
|
30
30
|
readonly description = "Sign data with a quantum-safe PQC key (ML-DSA, SLH-DSA, or FN-DSA). Returns a base64-encoded signature. Use this when an agent needs to cryptographically attest to data it produced or decisions it made.";
|
|
@@ -33,7 +33,7 @@ export declare class QnspSignDataTool extends StructuredTool {
|
|
|
33
33
|
data: z.ZodString;
|
|
34
34
|
context: z.ZodOptional<z.ZodString>;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
|
-
constructor(config:
|
|
36
|
+
constructor(config: QnsiKmsToolConfig, fields?: ToolParams);
|
|
37
37
|
protected _call(input: z.infer<typeof signDataSchema>): Promise<string>;
|
|
38
38
|
}
|
|
39
39
|
declare const verifySignatureSchema: z.ZodObject<{
|
|
@@ -45,7 +45,7 @@ declare const verifySignatureSchema: z.ZodObject<{
|
|
|
45
45
|
/**
|
|
46
46
|
* LangChain tool that verifies a PQC signature against data and a key.
|
|
47
47
|
*/
|
|
48
|
-
export declare class
|
|
48
|
+
export declare class QnsiVerifySignatureTool extends StructuredTool {
|
|
49
49
|
#private;
|
|
50
50
|
readonly name = "qnsp_verify_signature";
|
|
51
51
|
readonly description = "Verify a quantum-safe PQC signature. Returns true/false and the algorithm used. Use this when an agent needs to verify the authenticity of data or attestations from other agents or services.";
|
|
@@ -55,7 +55,7 @@ export declare class QnspVerifySignatureTool extends StructuredTool {
|
|
|
55
55
|
signature: z.ZodString;
|
|
56
56
|
context: z.ZodOptional<z.ZodString>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
|
-
constructor(config:
|
|
58
|
+
constructor(config: QnsiKmsToolConfig, fields?: ToolParams);
|
|
59
59
|
protected _call(input: z.infer<typeof verifySignatureSchema>): Promise<string>;
|
|
60
60
|
}
|
|
61
61
|
export {};
|
|
@@ -21,7 +21,7 @@ const signDataSchema = z.object({
|
|
|
21
21
|
/**
|
|
22
22
|
* LangChain tool that signs data with a PQC key (ML-DSA / SLH-DSA / FN-DSA).
|
|
23
23
|
*/
|
|
24
|
-
export class
|
|
24
|
+
export class QnsiSignDataTool extends StructuredTool {
|
|
25
25
|
name = "qnsp_sign_data";
|
|
26
26
|
description = "Sign data with a quantum-safe PQC key (ML-DSA, SLH-DSA, or FN-DSA). Returns a base64-encoded signature. Use this when an agent needs to cryptographically attest to data it produced or decisions it made.";
|
|
27
27
|
schema = signDataSchema;
|
|
@@ -75,7 +75,7 @@ const verifySignatureSchema = z.object({
|
|
|
75
75
|
/**
|
|
76
76
|
* LangChain tool that verifies a PQC signature against data and a key.
|
|
77
77
|
*/
|
|
78
|
-
export class
|
|
78
|
+
export class QnsiVerifySignatureTool extends StructuredTool {
|
|
79
79
|
name = "qnsp_verify_signature";
|
|
80
80
|
description = "Verify a quantum-safe PQC signature. Returns true/false and the algorithm used. Use this when an agent needs to verify the authenticity of data or attestations from other agents or services.";
|
|
81
81
|
schema = verifySignatureSchema;
|
|
@@ -13,7 +13,7 @@ declare const readSecretSchema: z.ZodObject<{
|
|
|
13
13
|
/**
|
|
14
14
|
* LangChain tool that reads a PQC-encrypted secret from QNSP Vault.
|
|
15
15
|
*/
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class QnsiReadSecretTool extends StructuredTool {
|
|
17
17
|
#private;
|
|
18
18
|
readonly name = "qnsp_read_secret";
|
|
19
19
|
readonly description = "Read a PQC-encrypted secret from QNSP Vault. Returns the secret name and encrypted envelope. Use this when an agent needs to retrieve a stored credential, API key, or sensitive value.";
|
|
@@ -32,7 +32,7 @@ declare const writeSecretSchema: z.ZodObject<{
|
|
|
32
32
|
/**
|
|
33
33
|
* LangChain tool that stores a PQC-encrypted secret in QNSP Vault.
|
|
34
34
|
*/
|
|
35
|
-
export declare class
|
|
35
|
+
export declare class QnsiWriteSecretTool extends StructuredTool {
|
|
36
36
|
#private;
|
|
37
37
|
readonly name = "qnsp_write_secret";
|
|
38
38
|
readonly description = "Store a PQC-encrypted secret in QNSP Vault. The payload must be base64-encoded. Returns the created secret ID. Use this when an agent needs to persist a credential, token, or sensitive value securely.";
|
|
@@ -53,7 +53,7 @@ declare const rotateSecretSchema: z.ZodObject<{
|
|
|
53
53
|
/**
|
|
54
54
|
* LangChain tool that rotates a secret in QNSP Vault with a new value.
|
|
55
55
|
*/
|
|
56
|
-
export declare class
|
|
56
|
+
export declare class QnsiRotateSecretTool extends StructuredTool {
|
|
57
57
|
#private;
|
|
58
58
|
readonly name = "qnsp_rotate_secret";
|
|
59
59
|
readonly description = "Rotate a secret in QNSP Vault with a new PQC-encrypted value. The previous version is retained for rollback. Use this when an agent needs to update a credential after rotation.";
|
|
@@ -13,7 +13,7 @@ const readSecretSchema = z.object({
|
|
|
13
13
|
/**
|
|
14
14
|
* LangChain tool that reads a PQC-encrypted secret from QNSP Vault.
|
|
15
15
|
*/
|
|
16
|
-
export class
|
|
16
|
+
export class QnsiReadSecretTool extends StructuredTool {
|
|
17
17
|
name = "qnsp_read_secret";
|
|
18
18
|
description = "Read a PQC-encrypted secret from QNSP Vault. Returns the secret name and encrypted envelope. Use this when an agent needs to retrieve a stored credential, API key, or sensitive value.";
|
|
19
19
|
schema = readSecretSchema;
|
|
@@ -47,7 +47,7 @@ const writeSecretSchema = z.object({
|
|
|
47
47
|
/**
|
|
48
48
|
* LangChain tool that stores a PQC-encrypted secret in QNSP Vault.
|
|
49
49
|
*/
|
|
50
|
-
export class
|
|
50
|
+
export class QnsiWriteSecretTool extends StructuredTool {
|
|
51
51
|
name = "qnsp_write_secret";
|
|
52
52
|
description = "Store a PQC-encrypted secret in QNSP Vault. The payload must be base64-encoded. Returns the created secret ID. Use this when an agent needs to persist a credential, token, or sensitive value securely.";
|
|
53
53
|
schema = writeSecretSchema;
|
|
@@ -81,7 +81,7 @@ const rotateSecretSchema = z.object({
|
|
|
81
81
|
/**
|
|
82
82
|
* LangChain tool that rotates a secret in QNSP Vault with a new value.
|
|
83
83
|
*/
|
|
84
|
-
export class
|
|
84
|
+
export class QnsiRotateSecretTool extends StructuredTool {
|
|
85
85
|
name = "qnsp_rotate_secret";
|
|
86
86
|
description = "Rotate a secret in QNSP Vault with a new PQC-encrypted value. The previous version is retained for rollback. Use this when an agent needs to update a credential after rotation.";
|
|
87
87
|
schema = rotateSecretSchema;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* consolidation): Bearer auth, `x-qnsp-tenant-id` header, 429 retry with
|
|
7
7
|
* exponential backoff + `Retry-After`, per-request timeout, `Vault API
|
|
8
8
|
* error: <status> <statusText>` on failure. Endpoints and request/response
|
|
9
|
-
* shapes are byte-for-byte preserved. Activation is owned by `
|
|
9
|
+
* shapes are byte-for-byte preserved. Activation is owned by `QnsiToolkit`
|
|
10
10
|
* (single `langchain-qnsp` handshake); the resolved tenant id is injected via
|
|
11
11
|
* {@link VaultClient.setTenantId} — so this subpath has no `@heossi/qnsi-*`
|
|
12
12
|
* workspace dependency (same pattern as `../_activation`).
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* consolidation): Bearer auth, `x-qnsp-tenant-id` header, 429 retry with
|
|
7
7
|
* exponential backoff + `Retry-After`, per-request timeout, `Vault API
|
|
8
8
|
* error: <status> <statusText>` on failure. Endpoints and request/response
|
|
9
|
-
* shapes are byte-for-byte preserved. Activation is owned by `
|
|
9
|
+
* shapes are byte-for-byte preserved. Activation is owned by `QnsiToolkit`
|
|
10
10
|
* (single `langchain-qnsp` handshake); the resolved tenant id is injected via
|
|
11
11
|
* {@link VaultClient.setTenantId} — so this subpath has no `@heossi/qnsi-*`
|
|
12
12
|
* workspace dependency (same pattern as `../_activation`).
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {
|
|
9
|
+
* import { QnsiVectorStore } from "@heossi/qnsi/llamaindex";
|
|
10
10
|
*
|
|
11
|
-
* const store = new
|
|
11
|
+
* const store = new QnsiVectorStore({ apiKey: process.env.QNSP_API_KEY });
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export type {
|
|
15
|
-
export {
|
|
14
|
+
export type { QnsiVectorStoreConfig, SearchSecurityEnvelope, TextNode, VectorStoreQuery, VectorStoreQueryResult, } from "./vector-store.js";
|
|
15
|
+
export { QnsiVectorStore } from "./vector-store.js";
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/llamaindex/index.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import {
|
|
9
|
+
* import { QnsiVectorStore } from "@heossi/qnsi/llamaindex";
|
|
10
10
|
*
|
|
11
|
-
* const store = new
|
|
11
|
+
* const store = new QnsiVectorStore({ apiKey: process.env.QNSP_API_KEY });
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export {
|
|
14
|
+
export { QnsiVectorStore } from "./vector-store.js";
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -42,7 +42,7 @@ export interface VectorStoreQueryResult {
|
|
|
42
42
|
readonly similarities: number[];
|
|
43
43
|
readonly ids: string[];
|
|
44
44
|
}
|
|
45
|
-
export interface
|
|
45
|
+
export interface QnsiVectorStoreConfig {
|
|
46
46
|
/**
|
|
47
47
|
* QNSP API key. Get one at https://cloud.qnsi.heossi.com/api-keys
|
|
48
48
|
* The API key carries the tenant ID internally — no separate tenantId needed.
|
|
@@ -70,16 +70,16 @@ export interface QnspVectorStoreConfig {
|
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
73
|
-
* import {
|
|
73
|
+
* import { QnsiVectorStore } from "@heossi/qnsi/llamaindex";
|
|
74
74
|
*
|
|
75
|
-
* const store = new
|
|
75
|
+
* const store = new QnsiVectorStore({ apiKey: process.env.QNSP_API_KEY });
|
|
76
76
|
* await store.add([{ id_: "doc-1", text: "Quantum-safe overview", metadata: {} }]);
|
|
77
77
|
* const result = await store.query({ queryStr: "post-quantum cryptography" });
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
export declare class
|
|
80
|
+
export declare class QnsiVectorStore {
|
|
81
81
|
#private;
|
|
82
|
-
constructor(config:
|
|
82
|
+
constructor(config: QnsiVectorStoreConfig);
|
|
83
83
|
/**
|
|
84
84
|
* Add nodes to the QNSP encrypted search index. Returns indexed node IDs.
|
|
85
85
|
*/
|
|
@@ -212,20 +212,20 @@ class SearchTransport {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
// ───
|
|
215
|
+
// ─── QnsiVectorStore ──────────────────────────────────────────────────────────
|
|
216
216
|
/**
|
|
217
217
|
* LlamaIndex-compatible vector store backed by QNSP encrypted search (SSE-X).
|
|
218
218
|
*
|
|
219
219
|
* @example
|
|
220
220
|
* ```typescript
|
|
221
|
-
* import {
|
|
221
|
+
* import { QnsiVectorStore } from "@heossi/qnsi/llamaindex";
|
|
222
222
|
*
|
|
223
|
-
* const store = new
|
|
223
|
+
* const store = new QnsiVectorStore({ apiKey: process.env.QNSP_API_KEY });
|
|
224
224
|
* await store.add([{ id_: "doc-1", text: "Quantum-safe overview", metadata: {} }]);
|
|
225
225
|
* const result = await store.query({ queryStr: "post-quantum cryptography" });
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
|
-
export class
|
|
228
|
+
export class QnsiVectorStore {
|
|
229
229
|
#transport;
|
|
230
230
|
#sourceService;
|
|
231
231
|
#apiKey;
|
package/dist/storage.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class StorageClient {
|
|
|
20
20
|
constructor(internal: Internal);
|
|
21
21
|
putObject(bucket: string, key: string, input: PutObjectInput, opts?: Pick<RequestOptions, "idempotencyKey">): Promise<Record<string, unknown>>;
|
|
22
22
|
/**
|
|
23
|
-
* Returns `[plaintext bytes, descriptor JSON]`. Throws `
|
|
23
|
+
* Returns `[plaintext bytes, descriptor JSON]`. Throws `QnsiApiError`
|
|
24
24
|
* if the descriptor is missing the dataB64 field.
|
|
25
25
|
*/
|
|
26
26
|
getObject(bucket: string, key: string): Promise<readonly [Uint8Array, GetObjectResponse]>;
|
package/dist/storage.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* (apps/storage-service/src/routes/bucket-objects.ts) and reached via the edge gateway's
|
|
5
5
|
* `/proxy/storage` prefix (rewritten to `/storage`).
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { QnsiApiError } from "./errors.js";
|
|
8
8
|
// Edge gateway rewrites /proxy/storage -> /storage, so this resolves to the backend's
|
|
9
9
|
// /storage/v1/buckets/* routes. (Was /proxy/storage/storage/v1 — a double "storage" that
|
|
10
10
|
// rewrote to /storage/storage/v1, which the backend never served, so every call 404'd.)
|
|
@@ -27,13 +27,13 @@ export class StorageClient {
|
|
|
27
27
|
return this.internal.request("PUT", `${PATH_PREFIX}/buckets/${bucket}/objects/${key}`, body, opts);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Returns `[plaintext bytes, descriptor JSON]`. Throws `
|
|
30
|
+
* Returns `[plaintext bytes, descriptor JSON]`. Throws `QnsiApiError`
|
|
31
31
|
* if the descriptor is missing the dataB64 field.
|
|
32
32
|
*/
|
|
33
33
|
async getObject(bucket, key) {
|
|
34
34
|
const resp = await this.internal.request("GET", `${PATH_PREFIX}/buckets/${bucket}/objects/${key}`);
|
|
35
35
|
if (!resp.dataB64) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new QnsiApiError("storage.getObject: response missing dataB64", 200);
|
|
37
37
|
}
|
|
38
38
|
return [decodeB64(resp.dataB64), resp];
|
|
39
39
|
}
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/** Default replay-protection window — 5 minutes. */
|
|
8
8
|
export declare const MAX_WEBHOOK_SKEW_MS: number;
|
|
9
|
-
export interface
|
|
9
|
+
export interface QnsiWebhookEvent {
|
|
10
10
|
readonly eventType: string;
|
|
11
11
|
readonly eventId: string;
|
|
12
12
|
readonly occurredAt: string;
|
|
@@ -16,17 +16,17 @@ export interface QnspWebhookEvent {
|
|
|
16
16
|
* Constant-time HMAC-SHA-256 verification. The header must be of the
|
|
17
17
|
* form `sha256=<hex>`.
|
|
18
18
|
*/
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function verifyQnsiWebhookSignature(body: Uint8Array | string, signatureHeader: string, secret: string): void;
|
|
20
20
|
/**
|
|
21
21
|
* Verify the HMAC, enforce replay protection, parse the JSON body, and
|
|
22
|
-
* return a typed `
|
|
22
|
+
* return a typed `QnsiWebhookEvent`.
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function parseQnsiWebhook(input: {
|
|
25
25
|
readonly body: Uint8Array | string;
|
|
26
26
|
readonly signatureHeader: string;
|
|
27
27
|
readonly timestampHeader?: string;
|
|
28
28
|
readonly secret: string;
|
|
29
29
|
readonly maxSkewMs?: number;
|
|
30
30
|
readonly now?: Date;
|
|
31
|
-
}):
|
|
31
|
+
}): QnsiWebhookEvent;
|
|
32
32
|
//# sourceMappingURL=webhooks.d.ts.map
|
package/dist/webhooks.js
CHANGED
|
@@ -5,46 +5,46 @@
|
|
|
5
5
|
* body. Always verify the **raw bytes** before parsing JSON.
|
|
6
6
|
*/
|
|
7
7
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
8
|
-
import {
|
|
8
|
+
import { QnsiWebhookError } from "./errors.js";
|
|
9
9
|
/** Default replay-protection window — 5 minutes. */
|
|
10
10
|
export const MAX_WEBHOOK_SKEW_MS = 5 * 60 * 1000;
|
|
11
11
|
/**
|
|
12
12
|
* Constant-time HMAC-SHA-256 verification. The header must be of the
|
|
13
13
|
* form `sha256=<hex>`.
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function verifyQnsiWebhookSignature(body, signatureHeader, secret) {
|
|
16
16
|
if (!signatureHeader.startsWith("sha256=")) {
|
|
17
|
-
throw new
|
|
17
|
+
throw new QnsiWebhookError("signature header must start with 'sha256='");
|
|
18
18
|
}
|
|
19
19
|
const expectedHex = signatureHeader.slice("sha256=".length);
|
|
20
20
|
const expected = Buffer.from(expectedHex, "hex");
|
|
21
21
|
if (expected.length === 0) {
|
|
22
|
-
throw new
|
|
22
|
+
throw new QnsiWebhookError("signature is not valid hex");
|
|
23
23
|
}
|
|
24
24
|
const bodyBytes = typeof body === "string" ? Buffer.from(body, "utf8") : Buffer.from(body);
|
|
25
25
|
const actual = createHmac("sha256", secret).update(bodyBytes).digest();
|
|
26
26
|
if (actual.length !== expected.length || !timingSafeEqual(actual, expected)) {
|
|
27
|
-
throw new
|
|
27
|
+
throw new QnsiWebhookError("signature mismatch");
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Verify the HMAC, enforce replay protection, parse the JSON body, and
|
|
32
|
-
* return a typed `
|
|
32
|
+
* return a typed `QnsiWebhookEvent`.
|
|
33
33
|
*/
|
|
34
|
-
export function
|
|
35
|
-
|
|
34
|
+
export function parseQnsiWebhook(input) {
|
|
35
|
+
verifyQnsiWebhookSignature(input.body, input.signatureHeader, input.secret);
|
|
36
36
|
const skewMs = input.maxSkewMs ?? MAX_WEBHOOK_SKEW_MS;
|
|
37
37
|
if (input.timestampHeader !== undefined && input.timestampHeader.length > 0) {
|
|
38
38
|
const ts = Date.parse(input.timestampHeader);
|
|
39
39
|
if (Number.isNaN(ts)) {
|
|
40
|
-
throw new
|
|
40
|
+
throw new QnsiWebhookError("timestamp header is not RFC3339");
|
|
41
41
|
}
|
|
42
42
|
const reference = input.now ? input.now.getTime() : Date.now();
|
|
43
43
|
const delta = reference - ts;
|
|
44
44
|
if (delta > skewMs)
|
|
45
|
-
throw new
|
|
45
|
+
throw new QnsiWebhookError("timestamp is too old");
|
|
46
46
|
if (-delta > skewMs)
|
|
47
|
-
throw new
|
|
47
|
+
throw new QnsiWebhookError("timestamp is in the future");
|
|
48
48
|
}
|
|
49
49
|
const text = typeof input.body === "string" ? input.body : Buffer.from(input.body).toString("utf8");
|
|
50
50
|
let raw;
|
|
@@ -52,19 +52,19 @@ export function parseQnspWebhook(input) {
|
|
|
52
52
|
raw = JSON.parse(text);
|
|
53
53
|
}
|
|
54
54
|
catch {
|
|
55
|
-
throw new
|
|
55
|
+
throw new QnsiWebhookError("body is not valid JSON");
|
|
56
56
|
}
|
|
57
57
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
58
|
-
throw new
|
|
58
|
+
throw new QnsiWebhookError("body is not a JSON object");
|
|
59
59
|
}
|
|
60
60
|
const obj = raw;
|
|
61
61
|
const eventType = obj["event_type"];
|
|
62
62
|
const eventId = obj["event_id"];
|
|
63
63
|
if (typeof eventType !== "string") {
|
|
64
|
-
throw new
|
|
64
|
+
throw new QnsiWebhookError("missing event_type");
|
|
65
65
|
}
|
|
66
66
|
if (typeof eventId !== "string") {
|
|
67
|
-
throw new
|
|
67
|
+
throw new QnsiWebhookError("missing event_id");
|
|
68
68
|
}
|
|
69
69
|
const occurredAtRaw = obj["occurred_at"];
|
|
70
70
|
const occurredAt = typeof occurredAtRaw === "string" ? occurredAtRaw : "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heossi/qnsi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
],
|
|
97
97
|
"repository": {
|
|
98
98
|
"type": "git",
|
|
99
|
-
"url": "https://github.com/heossi-hq/
|
|
100
|
-
"directory": "packages/
|
|
99
|
+
"url": "https://github.com/heossi-hq/qnsi-public",
|
|
100
|
+
"directory": "packages/qnsi"
|
|
101
101
|
},
|
|
102
102
|
"homepage": "https://cloud.qnsi.heossi.com",
|
|
103
103
|
"bugs": {
|
|
104
|
-
"url": "https://github.com/heossi-hq/
|
|
104
|
+
"url": "https://github.com/heossi-hq/qnsi-public/issues"
|
|
105
105
|
},
|
|
106
106
|
"files": [
|
|
107
107
|
"dist/**/*",
|