@k9o/kibo 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,259 @@
1
+ // src/client-factory.ts
2
+ import "@k9o/core/http";
3
+
4
+ // src/vault.ts
5
+ import { request } from "@k9o/core/http";
6
+ import { projectPath } from "@k9o/core/url-grammar";
7
+ import { KError } from "@k9o/core/errors";
8
+ function encodeBase64Utf8(plaintext) {
9
+ return btoa(unescape(encodeURIComponent(plaintext)));
10
+ }
11
+ function decodeBase64Utf8(b64) {
12
+ return decodeURIComponent(escape(atob(b64)));
13
+ }
14
+ function requireProjectSlug(config) {
15
+ if (config.projectSlug === void 0 || config.projectSlug.length === 0) {
16
+ throw new KError({
17
+ code: "K9O_MISSING_PROJECT_CONTEXT",
18
+ message: "client.kibo.vault requires a bound projectSlug (member-plane resource)",
19
+ context: {},
20
+ recommendation: "Pass projectSlug when constructing the client."
21
+ });
22
+ }
23
+ return config.projectSlug;
24
+ }
25
+ function makeVaultNamespace(config) {
26
+ return {
27
+ /** ZK-DEK opaque store/fetch (ch08 §11.3.2 F.5). */
28
+ zkDeks: {
29
+ /**
30
+ * Store an opaque customer-wrapped DEK envelope.
31
+ * `POST /@<projectSlug>/vault/zk-deks` → the `zkdek_<base62>` handle.
32
+ * The SDK ships the envelope verbatim; it is never parsed here.
33
+ */
34
+ async store(input) {
35
+ return request(config, {
36
+ method: "POST",
37
+ path: projectPath(requireProjectSlug(config), "vault/zk-deks"),
38
+ body: input
39
+ });
40
+ },
41
+ /**
42
+ * Fetch a stored `WrappedDek` by its handle.
43
+ * `GET /@<projectSlug>/vault/zk-deks/<id>` → the opaque envelope + the
44
+ * non-secret `provider`/`keyVersionRef` the caller needs to unwrap it.
45
+ */
46
+ async fetch(id) {
47
+ return request(config, {
48
+ method: "GET",
49
+ path: projectPath(requireProjectSlug(config), `vault/zk-deks/${encodeURIComponent(id)}`)
50
+ });
51
+ }
52
+ },
53
+ /**
54
+ * §14 typed secrets surface (`services/gateway/src/routes/vault-secrets.ts`) — the full family:
55
+ * list/get/create/revealChallenge/reveal/update/rotate/move/delete. Every operation on a NAMED
56
+ * secret (everything except `list`) requires `region` — live-verified against staging, not
57
+ * documented in the route's OpenAPI schema. `list` is the one exception (verified it does NOT
58
+ * need `region`).
59
+ *
60
+ * Response shapes for `update`/`rotate`/`move` are typed to what the gateway ACTUALLY returns
61
+ * (live-verified), not the OpenAPI's documented (and inaccurate for these three) `SecretSummary` —
62
+ * see the 🔴 notes on `UpdateSecretResult`/`RotateSecretResult`/`MoveSecretResult` in `types.ts`.
63
+ */
64
+ secrets: {
65
+ /** List secrets (metadata only — never lists ciphertext). `GET /@<projectSlug>/vault/secrets`.
66
+ * The one secrets operation that does NOT need `region` (live-verified). */
67
+ async list(input) {
68
+ return request(config, {
69
+ method: "GET",
70
+ path: projectPath(requireProjectSlug(config), "vault/secrets"),
71
+ query: { prefix: input?.prefix, cursor: input?.cursor, limit: input?.limit }
72
+ });
73
+ },
74
+ /**
75
+ * Read a secret's metadata (never its value — use `revealChallenge`+`reveal` for that).
76
+ * `GET /@<projectSlug>/vault/secrets/<name>?region=<region>`.
77
+ *
78
+ * 🔴 KNOWN LIVE BUG (staging, 2026-09-05): this call currently fails with
79
+ * `K9O_REVEAL_CHALLENGE_REQUIRED` on every attempt — the gateway/kibo does not honor the
80
+ * documented "no `X-K9O-Reveal-Challenge` header ⇒ return metadata" behavior; it demands a
81
+ * challenge unconditionally. Implemented per the documented contract (this is a backend defect,
82
+ * not a client workaround); `list({prefix: exactName})` is the current working alternative for a
83
+ * single secret's metadata until the gateway/kibo side is fixed.
84
+ */
85
+ async get(name, opts) {
86
+ return request(config, {
87
+ method: "GET",
88
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
89
+ query: { region: opts.region }
90
+ });
91
+ },
92
+ /**
93
+ * Create a secret under the caller's own auth.
94
+ * `POST /@<projectSlug>/vault/secrets/<name>?region=<region>` → the `sec_<base62>` summary.
95
+ *
96
+ * 🔴 `region` is REQUIRED on the query string, live-verified against staging — the vault-forward
97
+ * proxy fail-closes with `K9O_INVALID_FIELD_VALUE` ("this request requires an authoritative
98
+ * region") without it. Distinct from any `region` carried inside `input.value`'s envelope (e.g.
99
+ * the BYOS aws_sigv4 STS-signing region): this one scopes the vault WRITE itself, mirroring the
100
+ * gateway's `gatewayRegion()` residency guard (region-guard.ts) that closed a 2026-08 wrong-region
101
+ * incident for the audit path — the request-shape unit tests never caught this because they don't
102
+ * exercise a real gateway.
103
+ */
104
+ async create(input) {
105
+ const { name, region, value, ...rest } = input;
106
+ return request(config, {
107
+ method: "POST",
108
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
109
+ query: { region },
110
+ // Live-verified against staging: the wire `value` MUST be base64 — a raw plaintext string
111
+ // (matching the route's own "the plaintext to seal" OpenAPI description literally) is
112
+ // rejected with K9O_INVALID_FIELD_VALUE "Request body could not be parsed." `input.value`
113
+ // stays the caller-facing plaintext; base64 is purely a wire-transport detail handled here.
114
+ body: { ...rest, value: encodeBase64Utf8(value) }
115
+ });
116
+ },
117
+ /** Mint a single-use reveal challenge — present it as `X-K9O-Reveal-Challenge` on the
118
+ * immediately-following `reveal()` call. `POST .../<name>?op=reveal-challenge&region=<region>`. */
119
+ async revealChallenge(name, opts) {
120
+ return request(config, {
121
+ method: "POST",
122
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
123
+ query: { op: "reveal-challenge", region: opts.region }
124
+ });
125
+ },
126
+ /** Reveal a secret's plaintext value using a single-use challenge from `revealChallenge()`.
127
+ * `GET .../<name>?region=<region>` with `X-K9O-Reveal-Challenge`. Decodes the wire's base64
128
+ * `value` back to plaintext (live-verified: the reveal response's `value` is base64, symmetric
129
+ * with `create`'s encode). */
130
+ async reveal(name, opts) {
131
+ const envelope = await request(config, {
132
+ method: "GET",
133
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
134
+ query: { region: opts.region },
135
+ headers: { "X-K9O-Reveal-Challenge": opts.challenge }
136
+ });
137
+ return { ...envelope, data: { ...envelope.data, value: decodeBase64Utf8(envelope.data.value) } };
138
+ },
139
+ /** Update a secret's value (bumps version) — owner-only. `PUT .../<name>?region=<region>`.
140
+ * 🔴 Returns only `{id, name, version}` live (see `UpdateSecretResult`), not the full summary
141
+ * the OpenAPI schema documents — call `get()` after if you need the rest. */
142
+ async update(name, input) {
143
+ return request(config, {
144
+ method: "PUT",
145
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
146
+ query: { region: input.region },
147
+ body: { value: encodeBase64Utf8(input.value), ...input.metadata !== void 0 ? { metadata: input.metadata } : {} }
148
+ });
149
+ },
150
+ /** Rotate a secret's wrapping key (re-wraps under a fresh `kid`; content unchanged) — owner-only.
151
+ * `POST .../<name>?op=rotate&region=<region>`. */
152
+ async rotate(name, opts) {
153
+ return request(config, {
154
+ method: "POST",
155
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
156
+ query: { op: "rotate", region: opts.region }
157
+ });
158
+ },
159
+ /** Move (rename) a secret's hierarchical path — owner-only.
160
+ * `POST .../<name>?op=move&region=<region>`. */
161
+ async move(name, opts) {
162
+ return request(config, {
163
+ method: "POST",
164
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
165
+ query: { op: "move", region: opts.region },
166
+ body: { newPath: opts.newPath }
167
+ });
168
+ },
169
+ /** Retire a secret — owner-only. `DELETE .../<name>?region=<region>` → `204 No Content`. */
170
+ async delete(name, opts) {
171
+ return request(config, {
172
+ method: "DELETE",
173
+ path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),
174
+ query: { region: opts.region }
175
+ });
176
+ }
177
+ }
178
+ };
179
+ }
180
+
181
+ // src/client-factory.ts
182
+ function createKiboClient(config) {
183
+ return {
184
+ vault: makeVaultNamespace(config)
185
+ };
186
+ }
187
+
188
+ // src/crypto.ts
189
+ import { KError as KError2 } from "@k9o/core/errors";
190
+ var cachedWasm;
191
+ function setZkWasm(mod) {
192
+ cachedWasm = mod;
193
+ }
194
+ async function loadWasm() {
195
+ if (cachedWasm) return cachedWasm;
196
+ const pkg = ["..", "wasm", "kibo_kms_rest_ffi.js"].join("/");
197
+ try {
198
+ cachedWasm = await import(pkg);
199
+ } catch {
200
+ throw new KError2({
201
+ code: "KIBO_WASM_ERROR",
202
+ message: "the Kibo zero-knowledge core (wasm) is not bundled in this build of @k9o/kibo; encrypt and decrypt are unavailable",
203
+ context: {},
204
+ recommendation: "Install a release of @k9o/kibo that ships the core, or load it yourself."
205
+ });
206
+ }
207
+ return cachedWasm;
208
+ }
209
+ async function encrypt(input) {
210
+ const wasm = await loadWasm();
211
+ let out;
212
+ try {
213
+ out = await wasm.zk_encrypt(input);
214
+ } catch (e) {
215
+ throw mapZkError(e);
216
+ }
217
+ return { envelope: toBytes(out.envelope) };
218
+ }
219
+ async function decrypt(input) {
220
+ const wasm = await loadWasm();
221
+ let out;
222
+ try {
223
+ out = await wasm.zk_decrypt(input);
224
+ } catch (e) {
225
+ throw mapZkError(e);
226
+ }
227
+ return { plaintext: toBytes(out.plaintext) };
228
+ }
229
+ function toBytes(v) {
230
+ if (v instanceof Uint8Array) return v;
231
+ if (Array.isArray(v)) return Uint8Array.from(v);
232
+ throw new KError2({
233
+ code: "KIBO_WASM_DECODE_ERROR",
234
+ message: "ZK core returned a non-byte value where bytes were expected",
235
+ context: {}
236
+ });
237
+ }
238
+ function mapZkError(e) {
239
+ if (e instanceof KError2) return e;
240
+ const raw = e instanceof Error ? e.message : String(e);
241
+ const head = /^([A-Z][A-Z0-9_]*):\s*([\s\S]*)$/.exec(raw);
242
+ const code = head?.[1] ?? "KIBO_WASM_ERROR";
243
+ let message = head?.[2] ?? raw;
244
+ let context = {};
245
+ const pv = /\(dimension:\s*([^,]+),\s*requested:\s*([^,]+),\s*declared:\s*([^)]+)\)\s*$/.exec(message);
246
+ if (pv) {
247
+ context = { dimension: pv[1].trim(), requested: pv[2].trim(), declared: pv[3].trim() };
248
+ message = message.slice(0, pv.index).trim();
249
+ }
250
+ return new KError2({ code, message, context });
251
+ }
252
+ export {
253
+ createKiboClient,
254
+ decrypt,
255
+ encrypt,
256
+ makeVaultNamespace,
257
+ setZkWasm
258
+ };
259
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client-factory.ts","../src/vault.ts","../src/crypto.ts"],"sourcesContent":["/**\n * `createKiboClient(config)` — per-instance Kibo (ZK vault) SDK factory.\n *\n * Composes into `@k9o/core` as `client.kibo` (re-export, available when a\n * project is bound — the same composition pattern as `@k9o/gate`). Reuses the\n * core HTTP layer (`@k9o/core/http`) so the bearer/header/retry contract is\n * identical to the rest of the SDK pool.\n */\n\nimport { type HttpClientConfig } from \"@k9o/core/http\";\nimport { makeVaultNamespace } from \"./vault.ts\";\n\n/** Shape of the per-instance client returned by `createKiboClient`. */\nexport type KiboClient = {\n /** Vault surface — `client.kibo.vault.zkDeks.{store,fetch}` (ch08 §11.3.2 F.5). */\n vault: ReturnType<typeof makeVaultNamespace>;\n};\n\n/** Construct a Kibo client bound to the supplied (core) HTTP config. */\nexport function createKiboClient(config: HttpClientConfig): KiboClient {\n return {\n vault: makeVaultNamespace(config),\n };\n}\n","/**\n * `client.kibo.vault.*` — the Kibo vault surface.\n *\n * v0.1.0: `vault.zkDeks.{store,fetch}` (ch08 §11.3.2 F.5) — member-plane,\n * project-scoped storage of the opaque customer-wrapped DEK envelope. Zero\n * crypto SDK-side: this is a plain authenticated REST round-trip carrying an\n * opaque blob (the wrapping happens in the ZK core, piece C). The encryption\n * surface (`kibo.encrypt`/`decrypt`) lands in a later version once the C\n * binding is consumable.\n */\n\nimport { request, type HttpClientConfig } from \"@k9o/core/http\";\nimport { projectPath } from \"@k9o/core/url-grammar\";\nimport { KError } from \"@k9o/core/errors\";\nimport type { Envelope } from \"@k9o/core/envelope\";\nimport type {\n StoreZkDekInput, ZkDekHandle, ZkDekRecord,\n CreateSecretInput, SecretSummary, ListSecretsInput, ListSecretsResult,\n RevealChallenge, RevealSecretResult, UpdateSecretInput, UpdateSecretResult,\n RotateSecretResult, MoveSecretResult,\n} from \"./types.ts\";\n\n/** UTF-8-safe base64 encode, usable across browser/Node/Bun (unlike `Buffer`) — the vault-secrets wire\n * `value` field is base64 (live-verified; the OpenAPI \"plaintext to seal\" description does not mean\n * raw-on-the-wire). */\nfunction encodeBase64Utf8(plaintext: string): string {\n return btoa(unescape(encodeURIComponent(plaintext)));\n}\n\n/** Inverse of {@link encodeBase64Utf8} — decodes a revealed wire `value` back to plaintext. */\nfunction decodeBase64Utf8(b64: string): string {\n return decodeURIComponent(escape(atob(b64)));\n}\n\n/** Both `vault.zkDeks` and `vault.secrets` require a project context (member-plane, ch08 §11.3/§14). */\nfunction requireProjectSlug(config: HttpClientConfig): string {\n if (config.projectSlug === undefined || config.projectSlug.length === 0) {\n throw new KError({\n code: \"K9O_MISSING_PROJECT_CONTEXT\",\n message: \"client.kibo.vault requires a bound projectSlug (member-plane resource)\",\n context: {},\n recommendation: \"Pass projectSlug when constructing the client.\",\n });\n }\n return config.projectSlug;\n}\n\nexport function makeVaultNamespace(config: HttpClientConfig) {\n return {\n /** ZK-DEK opaque store/fetch (ch08 §11.3.2 F.5). */\n zkDeks: {\n /**\n * Store an opaque customer-wrapped DEK envelope.\n * `POST /@<projectSlug>/vault/zk-deks` → the `zkdek_<base62>` handle.\n * The SDK ships the envelope verbatim; it is never parsed here.\n */\n async store(input: StoreZkDekInput): Promise<Envelope<ZkDekHandle>> {\n return request<ZkDekHandle>(config, {\n method: \"POST\",\n path: projectPath(requireProjectSlug(config), \"vault/zk-deks\"),\n body: input,\n });\n },\n\n /**\n * Fetch a stored `WrappedDek` by its handle.\n * `GET /@<projectSlug>/vault/zk-deks/<id>` → the opaque envelope + the\n * non-secret `provider`/`keyVersionRef` the caller needs to unwrap it.\n */\n async fetch(id: string): Promise<Envelope<ZkDekRecord>> {\n return request<ZkDekRecord>(config, {\n method: \"GET\",\n path: projectPath(requireProjectSlug(config), `vault/zk-deks/${encodeURIComponent(id)}`),\n });\n },\n },\n\n /**\n * §14 typed secrets surface (`services/gateway/src/routes/vault-secrets.ts`) — the full family:\n * list/get/create/revealChallenge/reveal/update/rotate/move/delete. Every operation on a NAMED\n * secret (everything except `list`) requires `region` — live-verified against staging, not\n * documented in the route's OpenAPI schema. `list` is the one exception (verified it does NOT\n * need `region`).\n *\n * Response shapes for `update`/`rotate`/`move` are typed to what the gateway ACTUALLY returns\n * (live-verified), not the OpenAPI's documented (and inaccurate for these three) `SecretSummary` —\n * see the 🔴 notes on `UpdateSecretResult`/`RotateSecretResult`/`MoveSecretResult` in `types.ts`.\n */\n secrets: {\n /** List secrets (metadata only — never lists ciphertext). `GET /@<projectSlug>/vault/secrets`.\n * The one secrets operation that does NOT need `region` (live-verified). */\n async list(input?: ListSecretsInput): Promise<Envelope<ListSecretsResult>> {\n return request<ListSecretsResult>(config, {\n method: \"GET\",\n path: projectPath(requireProjectSlug(config), \"vault/secrets\"),\n query: { prefix: input?.prefix, cursor: input?.cursor, limit: input?.limit },\n });\n },\n\n /**\n * Read a secret's metadata (never its value — use `revealChallenge`+`reveal` for that).\n * `GET /@<projectSlug>/vault/secrets/<name>?region=<region>`.\n *\n * 🔴 KNOWN LIVE BUG (staging, 2026-09-05): this call currently fails with\n * `K9O_REVEAL_CHALLENGE_REQUIRED` on every attempt — the gateway/kibo does not honor the\n * documented \"no `X-K9O-Reveal-Challenge` header ⇒ return metadata\" behavior; it demands a\n * challenge unconditionally. Implemented per the documented contract (this is a backend defect,\n * not a client workaround); `list({prefix: exactName})` is the current working alternative for a\n * single secret's metadata until the gateway/kibo side is fixed.\n */\n async get(name: string, opts: { region: string }): Promise<Envelope<SecretSummary>> {\n return request<SecretSummary>(config, {\n method: \"GET\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { region: opts.region },\n });\n },\n\n /**\n * Create a secret under the caller's own auth.\n * `POST /@<projectSlug>/vault/secrets/<name>?region=<region>` → the `sec_<base62>` summary.\n *\n * 🔴 `region` is REQUIRED on the query string, live-verified against staging — the vault-forward\n * proxy fail-closes with `K9O_INVALID_FIELD_VALUE` (\"this request requires an authoritative\n * region\") without it. Distinct from any `region` carried inside `input.value`'s envelope (e.g.\n * the BYOS aws_sigv4 STS-signing region): this one scopes the vault WRITE itself, mirroring the\n * gateway's `gatewayRegion()` residency guard (region-guard.ts) that closed a 2026-08 wrong-region\n * incident for the audit path — the request-shape unit tests never caught this because they don't\n * exercise a real gateway.\n */\n async create(input: CreateSecretInput): Promise<Envelope<SecretSummary>> {\n const { name, region, value, ...rest } = input;\n return request<SecretSummary>(config, {\n method: \"POST\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { region },\n // Live-verified against staging: the wire `value` MUST be base64 — a raw plaintext string\n // (matching the route's own \"the plaintext to seal\" OpenAPI description literally) is\n // rejected with K9O_INVALID_FIELD_VALUE \"Request body could not be parsed.\" `input.value`\n // stays the caller-facing plaintext; base64 is purely a wire-transport detail handled here.\n body: { ...rest, value: encodeBase64Utf8(value) },\n });\n },\n\n /** Mint a single-use reveal challenge — present it as `X-K9O-Reveal-Challenge` on the\n * immediately-following `reveal()` call. `POST .../<name>?op=reveal-challenge&region=<region>`. */\n async revealChallenge(name: string, opts: { region: string }): Promise<Envelope<RevealChallenge>> {\n return request<RevealChallenge>(config, {\n method: \"POST\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { op: \"reveal-challenge\", region: opts.region },\n });\n },\n\n /** Reveal a secret's plaintext value using a single-use challenge from `revealChallenge()`.\n * `GET .../<name>?region=<region>` with `X-K9O-Reveal-Challenge`. Decodes the wire's base64\n * `value` back to plaintext (live-verified: the reveal response's `value` is base64, symmetric\n * with `create`'s encode). */\n async reveal(name: string, opts: { region: string; challenge: string }): Promise<Envelope<RevealSecretResult>> {\n const envelope = await request<RevealSecretResult>(config, {\n method: \"GET\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { region: opts.region },\n headers: { \"X-K9O-Reveal-Challenge\": opts.challenge },\n });\n return { ...envelope, data: { ...envelope.data, value: decodeBase64Utf8(envelope.data.value) } };\n },\n\n /** Update a secret's value (bumps version) — owner-only. `PUT .../<name>?region=<region>`.\n * 🔴 Returns only `{id, name, version}` live (see `UpdateSecretResult`), not the full summary\n * the OpenAPI schema documents — call `get()` after if you need the rest. */\n async update(name: string, input: UpdateSecretInput): Promise<Envelope<UpdateSecretResult>> {\n return request<UpdateSecretResult>(config, {\n method: \"PUT\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { region: input.region },\n body: { value: encodeBase64Utf8(input.value), ...(input.metadata !== undefined ? { metadata: input.metadata } : {}) },\n });\n },\n\n /** Rotate a secret's wrapping key (re-wraps under a fresh `kid`; content unchanged) — owner-only.\n * `POST .../<name>?op=rotate&region=<region>`. */\n async rotate(name: string, opts: { region: string }): Promise<Envelope<RotateSecretResult>> {\n return request<RotateSecretResult>(config, {\n method: \"POST\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { op: \"rotate\", region: opts.region },\n });\n },\n\n /** Move (rename) a secret's hierarchical path — owner-only.\n * `POST .../<name>?op=move&region=<region>`. */\n async move(name: string, opts: { region: string; newPath: string }): Promise<Envelope<MoveSecretResult>> {\n return request<MoveSecretResult>(config, {\n method: \"POST\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { op: \"move\", region: opts.region },\n body: { newPath: opts.newPath },\n });\n },\n\n /** Retire a secret — owner-only. `DELETE .../<name>?region=<region>` → `204 No Content`. */\n async delete(name: string, opts: { region: string }): Promise<Envelope<void>> {\n return request<void>(config, {\n method: \"DELETE\",\n path: projectPath(requireProjectSlug(config), `vault/secrets/${encodeURIComponent(name)}`),\n query: { region: opts.region },\n });\n },\n },\n };\n}\n","/**\n * ZK encrypt/decrypt — the thin TS wrapper over the bound crypto core\n * (`kibo-kms-rest-ffi`, piece C) compiled to wasm. ZERO crypto here: every\n * wrap/unwrap, envelope framing, posture-floor enforcement, and KMS round-trip\n * lives in the audited Rust core. This layer only marshals the typed input\n * across the wasm boundary and maps the core's error string → `KError`.\n *\n * The core exposes `zk_encrypt`/`zk_decrypt` (async) taking/returning plain JS\n * objects via serde-wasm-bindgen, and rejecting with the `ZkFfiError` display\n * string (`\"<K9O_CODE>: <message>\"`, optionally with a posture-violation tail).\n *\n * Composes into `@k9o/core` as `client.kibo.encrypt`/`decrypt`; the F.5\n * `vault.zkDeks.{store,fetch}` surface (envelope persistence) is separate +\n * decoupled (the core never sees the store).\n */\n\nimport { KError } from \"@k9o/core/errors\";\nimport type {\n KiboEncryptInput,\n KiboEncryptOutput,\n KiboDecryptInput,\n KiboDecryptOutput,\n} from \"./crypto-types.ts\";\n\n/** The minimal surface the bound ZK-core wasm exposes. */\nexport interface ZkWasm {\n zk_encrypt(input: unknown): Promise<unknown>;\n zk_decrypt(input: unknown): Promise<unknown>;\n}\n\nlet cachedWasm: ZkWasm | undefined;\n\n/**\n * Inject a pre-loaded core wasm module. Hosts that bundle the wasm themselves\n * (browser/RN, or a test) call this; otherwise `encrypt`/`decrypt` lazy-load\n * the vendored per-provider artifact.\n */\nexport function setZkWasm(mod: ZkWasm): void {\n cachedWasm = mod;\n}\n\n/**\n * Lazily load the bound core wasm. ONE all-provider artifact is generated from\n * `kibo-kms-rest-ffi` (the core compiles every v2 KMS provider in; the\n * `provider` input field selects at call time), vendored under `wasm/` by the\n * publish pipeline and gitignored in-repo. The specifier is assembled at\n * runtime so the bundler/typechecker must not hard-resolve it — the contract\n * is the `ZkWasm` interface above.\n */\nasync function loadWasm(): Promise<ZkWasm> {\n if (cachedWasm) return cachedWasm;\n const pkg = [\"..\", \"wasm\", \"kibo_kms_rest_ffi.js\"].join(\"/\");\n try {\n cachedWasm = (await import(pkg)) as unknown as ZkWasm;\n } catch {\n // A package published without its native core (no bundle at publish time). Say so; never surface a bare\n // module-resolution error, and do not cache the failure.\n throw new KError({\n code: \"KIBO_WASM_ERROR\",\n message: \"the Kibo zero-knowledge core (wasm) is not bundled in this build of @k9o/kibo; encrypt and decrypt are unavailable\",\n context: {},\n recommendation: \"Install a release of @k9o/kibo that ships the core, or load it yourself.\",\n });\n }\n return cachedWasm;\n}\n\n/**\n * Encrypt `input.plaintext` via the customer KMS, client-side. Returns the\n * opaque ZKFE envelope — store it via `vault.zkDeks.store` (F.5) or keep it\n * yourself; it is meaningless to the platform.\n */\nexport async function encrypt(input: KiboEncryptInput): Promise<KiboEncryptOutput> {\n const wasm = await loadWasm();\n let out: unknown;\n try {\n out = await wasm.zk_encrypt(input);\n } catch (e) {\n throw mapZkError(e);\n }\n return { envelope: toBytes((out as { envelope?: unknown }).envelope) };\n}\n\n/**\n * Decrypt a ZKFE `input.envelope`. `strategy`, `attestation_tier`, and\n * `encryption_context` MUST match the values used at encrypt — they are AAD-bound\n * and never recovered from the envelope (anti-substitution discipline).\n */\nexport async function decrypt(input: KiboDecryptInput): Promise<KiboDecryptOutput> {\n const wasm = await loadWasm();\n let out: unknown;\n try {\n out = await wasm.zk_decrypt(input);\n } catch (e) {\n throw mapZkError(e);\n }\n return { plaintext: toBytes((out as { plaintext?: unknown }).plaintext) };\n}\n\n/** Normalise wasm byte output (serde-wasm-bindgen emits `Vec<u8>` as a number\n * array; some hosts return a `Uint8Array`) to `Uint8Array`. */\nfunction toBytes(v: unknown): Uint8Array {\n if (v instanceof Uint8Array) return v;\n if (Array.isArray(v)) return Uint8Array.from(v as number[]);\n throw new KError({\n code: \"KIBO_WASM_DECODE_ERROR\",\n message: \"ZK core returned a non-byte value where bytes were expected\",\n context: {},\n });\n}\n\n/**\n * Map the core's rejected error → `KError`. The wasm path flattens `ZkFfiError`\n * to its display string: `\"<CODE>: <message>\"` where `<CODE>` is a `K9O_*` wire\n * code (or `UPSTREAM_KMS_ERROR` for the customer's own KMS failures), optionally\n * followed by `\"(dimension: …, requested: …, declared: …)\"` for a posture-floor\n * violation. Codes are passed through (never hardcoded), per the KError discipline.\n */\nfunction mapZkError(e: unknown): KError {\n if (e instanceof KError) return e;\n const raw = e instanceof Error ? e.message : String(e);\n const head = /^([A-Z][A-Z0-9_]*):\\s*([\\s\\S]*)$/.exec(raw);\n const code = head?.[1] ?? \"KIBO_WASM_ERROR\";\n let message = head?.[2] ?? raw;\n\n let context: Record<string, unknown> = {};\n const pv = /\\(dimension:\\s*([^,]+),\\s*requested:\\s*([^,]+),\\s*declared:\\s*([^)]+)\\)\\s*$/.exec(message);\n if (pv) {\n context = { dimension: pv[1]!.trim(), requested: pv[2]!.trim(), declared: pv[3]!.trim() };\n message = message.slice(0, pv.index).trim();\n }\n return new KError({ code, message, context });\n}\n"],"mappings":";AASA,OAAsC;;;ACEtC,SAAS,eAAsC;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AAYvB,SAAS,iBAAiB,WAA2B;AACnD,SAAO,KAAK,SAAS,mBAAmB,SAAS,CAAC,CAAC;AACrD;AAGA,SAAS,iBAAiB,KAAqB;AAC7C,SAAO,mBAAmB,OAAO,KAAK,GAAG,CAAC,CAAC;AAC7C;AAGA,SAAS,mBAAmB,QAAkC;AAC5D,MAAI,OAAO,gBAAgB,UAAa,OAAO,YAAY,WAAW,GAAG;AACvE,UAAM,IAAI,OAAO;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,EACH;AACA,SAAO,OAAO;AAChB;AAEO,SAAS,mBAAmB,QAA0B;AAC3D,SAAO;AAAA;AAAA,IAEL,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,GAAG,CAAC,EAAG,KAAK,EAAE;AACxF,cAAU,QAAQ,MAAM,GAAG,GAAG,KAAK,EAAE,KAAK;AAAA,EAC5C;AACA,SAAO,IAAIA,QAAO,EAAE,MAAM,SAAS,QAAQ,CAAC;AAC9C;","names":["KError"]}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * `@k9o/kibo` — Zero-Knowledge BYOK/HYOK vault SDK types.
3
+ *
4
+ * v0.1.0 surface: the ZK-DEK store/fetch. The wrapped
5
+ * envelope is produced client-side by the audited ZK core (the
6
+ * `kibo-kms-rest` binding); this SDK ships it **verbatim and opaque** and never
7
+ * reads its interior — the strict-ZK invariant + envelope framing live in the
8
+ * core, never here.
9
+ */
10
+ /** Customer KMS/HSM provider — non-secret routing metadata (mirrors the ZK FFI provider selector). */
11
+ type KmsProvider = "aws-kms" | "gcp-kms" | "azure-kv" | "hashicorp-vault";
12
+ /**
13
+ * Input to store an opaque customer-wrapped DEK.
14
+ * `provider` + `keyVersionRef` are explicit non-secret fields the SDK supplies
15
+ * (vault-ops never parses the envelope to derive them).
16
+ */
17
+ type StoreZkDekInput = {
18
+ /** base64 opaque `WrappedDek` envelope (AEAD-sealed under the customer KEK). */
19
+ envelope: string;
20
+ /** Which customer KMS/HSM holds the wrapping KEK. */
21
+ provider: KmsProvider;
22
+ /** Customer key reference (KMS ARN / GCP resource / AKV id / Vault path). */
23
+ keyVersionRef: string;
24
+ };
25
+ /** Store response — the opaque `zkdek_<base62>` handle + creation timestamp. */
26
+ type ZkDekHandle = {
27
+ /** `zkdek_<base62>` handle. */
28
+ id: string;
29
+ createdAt: string;
30
+ };
31
+ /** Fetch response — the stored record: opaque envelope + non-secret metadata. */
32
+ type ZkDekRecord = {
33
+ id: string;
34
+ /** base64 opaque `WrappedDek` envelope, returned verbatim for the customer to unwrap. */
35
+ envelope: string;
36
+ provider: KmsProvider;
37
+ keyVersionRef: string;
38
+ createdAt: string;
39
+ };
40
+ /** §14.2 secret visibility — write ops (create/update) stay owner-only regardless of this tag. */
41
+ type SecretVisibility = {
42
+ kind: "private";
43
+ } | {
44
+ kind: "shared";
45
+ principals?: string[];
46
+ roles?: string[];
47
+ };
48
+ /** Input to create a vault secret (ch08 §14) — `POST /@<projectSlug>/vault/secrets/<name>?region=<region>`. */
49
+ type CreateSecretInput = {
50
+ /** Hierarchical path the secret is addressed under, e.g. `byos/s3-prod` (also the `:name` URL segment). */
51
+ name: string;
52
+ /** The plaintext to seal, as a regular (non-base64) string — `vault.secrets.create` base64-encodes
53
+ * it for the wire itself (live-verified against staging: the route's OpenAPI description says
54
+ * "the plaintext to seal" but a raw non-base64 `value` is rejected as unparseable). */
55
+ value: string;
56
+ /** The authoritative region for this vault write (sent as `?region=`), REQUIRED — the vault-forward
57
+ * proxy fail-closes without it (live-verified against staging, not documented in the route's
58
+ * OpenAPI schema as of this writing). Distinct from any region carried inside `value`'s own
59
+ * envelope. */
60
+ region: string;
61
+ visibility?: SecretVisibility;
62
+ metadata?: Record<string, string>;
63
+ };
64
+ /** A secret WITHOUT its sealed ciphertext — the create/list/read metadata shape. */
65
+ type SecretSummary = {
66
+ /** `sec_<base62>`. */
67
+ id: string;
68
+ name: string;
69
+ ownerId: string;
70
+ visibility: SecretVisibility;
71
+ version: number;
72
+ /** The wrapping-key id at this version. */
73
+ kid: string;
74
+ createdAt: string;
75
+ createdBy: string;
76
+ updatedAt: string;
77
+ updatedBy: string;
78
+ rotatedAt: string | null;
79
+ retiredAt: string | null;
80
+ metadata: Record<string, string>;
81
+ };
82
+ /** `client.kibo.vault.secrets.list()` input — none of these need `region` (live-verified: unlike every
83
+ * other secrets operation, list is NOT region-gated). */
84
+ type ListSecretsInput = {
85
+ /** Filter to a path prefix. */
86
+ prefix?: string;
87
+ cursor?: string;
88
+ limit?: number;
89
+ };
90
+ type ListSecretsResult = {
91
+ secrets: readonly SecretSummary[];
92
+ nextCursor: string | null;
93
+ };
94
+ /** §14.10 releasing-node observed attestation tier (K4) — present on every reveal. */
95
+ type AttestationTier = {
96
+ /** `attestation:destination:region` trust-tier URN. */
97
+ urn: string;
98
+ /** Node provenance: `platform` (Kibo-operated) or `client` (Private Perimeter). */
99
+ operator: string;
100
+ /** Whether node attestation was verified against the vendor PKI on the URN's attestation segment. */
101
+ verified: boolean;
102
+ };
103
+ /** `revealChallenge()` result — a single-use challenge to present on the immediately-following `reveal()`. */
104
+ type RevealChallenge = {
105
+ challenge: string;
106
+ expiresAt: string;
107
+ };
108
+ /** `reveal()` result. `value` is the decoded plaintext (the SDK base64-decodes the wire value, the
109
+ * inverse of `create`'s encode) — never the raw base64. */
110
+ type RevealSecretResult = {
111
+ id: string;
112
+ name: string;
113
+ version: number;
114
+ value: string;
115
+ revealedAt: string;
116
+ attestationTier: AttestationTier;
117
+ };
118
+ /** `update()` input. */
119
+ type UpdateSecretInput = {
120
+ /** The authoritative region for this write (sent as `?region=`), REQUIRED — same live-verified gate
121
+ * as `create`. */
122
+ region: string;
123
+ /** New plaintext — bumps `version`. The SDK base64-encodes it for the wire. */
124
+ value: string;
125
+ metadata?: Record<string, string>;
126
+ };
127
+ /**
128
+ * `update()` result — 🔴 live-verified NARROWER than the documented `SecretSummary`: the gateway
129
+ * returns only `{id, name, version}` on a real PUT, not the full summary the OpenAPI schema claims.
130
+ * Typed to what's actually observed rather than the aspirational doc shape; call `get()` afterward if
131
+ * the full summary is needed.
132
+ */
133
+ type UpdateSecretResult = {
134
+ id: string;
135
+ name: string;
136
+ version: number;
137
+ };
138
+ /**
139
+ * `rotate()` result — 🔴 live-verified shape, not documented anywhere in the OpenAPI schema (the route
140
+ * only declares `t.Union([SecretSummary, RevealChallengeResponse])`, which this matches neither).
141
+ * `ledgerSequenceNumber` is undocumented; kept as-observed.
142
+ */
143
+ type RotateSecretResult = {
144
+ id: string;
145
+ name: string;
146
+ version: number;
147
+ rotatedAt: string;
148
+ ledgerSequenceNumber: number;
149
+ };
150
+ /**
151
+ * `move()` result — 🔴 live-verified shape, also not the documented `SecretSummary`: no `version`, and
152
+ * an undocumented `event` field (`"SECRET_PATH_CHANGED"` observed; typed as `string` since only one
153
+ * sample was seen and a closed enum can't be asserted from one observation).
154
+ */
155
+ type MoveSecretResult = {
156
+ id: string;
157
+ name: string;
158
+ event: string;
159
+ };
160
+
161
+ export type { AttestationTier, CreateSecretInput, KmsProvider, ListSecretsInput, ListSecretsResult, MoveSecretResult, RevealChallenge, RevealSecretResult, RotateSecretResult, SecretSummary, SecretVisibility, StoreZkDekInput, UpdateSecretInput, UpdateSecretResult, ZkDekHandle, ZkDekRecord };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@k9o/kibo",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Kibo — Zero-Knowledge BYOK/HYOK vault SDK (client-side; composes into @k9o/core as client.kibo). ZK-DEK store/fetch (F.5) + encrypt/decrypt (thin wrappers over the audited bound core compiled to wasm).",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./types": {
15
+ "types": "./dist/types.d.ts",
16
+ "import": "./dist/types.js",
17
+ "default": "./dist/types.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "src",
22
+ "wasm",
23
+ "LICENSE",
24
+ "NOTICE",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "dist"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/k9o-dev",
36
+ "directory": "packages/kibo"
37
+ },
38
+ "dependencies": {
39
+ "@k9o/core": "1.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "bun-types": "^1.1.0",
43
+ "typescript": "^5.6.0"
44
+ },
45
+ "module": "./dist/index.js"
46
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `createKiboClient(config)` — per-instance Kibo (ZK vault) SDK factory.
3
+ *
4
+ * Composes into `@k9o/core` as `client.kibo` (re-export, available when a
5
+ * project is bound — the same composition pattern as `@k9o/gate`). Reuses the
6
+ * core HTTP layer (`@k9o/core/http`) so the bearer/header/retry contract is
7
+ * identical to the rest of the SDK pool.
8
+ */
9
+
10
+ import { type HttpClientConfig } from "@k9o/core/http";
11
+ import { makeVaultNamespace } from "./vault.ts";
12
+
13
+ /** Shape of the per-instance client returned by `createKiboClient`. */
14
+ export type KiboClient = {
15
+ /** Vault surface — `client.kibo.vault.zkDeks.{store,fetch}` (ch08 §11.3.2 F.5). */
16
+ vault: ReturnType<typeof makeVaultNamespace>;
17
+ };
18
+
19
+ /** Construct a Kibo client bound to the supplied (core) HTTP config. */
20
+ export function createKiboClient(config: HttpClientConfig): KiboClient {
21
+ return {
22
+ vault: makeVaultNamespace(config),
23
+ };
24
+ }