@k9o/kibo-react-native 0.1.0 → 1.1.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/README.md CHANGED
@@ -1,35 +1,173 @@
1
1
  # @k9o/kibo-react-native
2
2
 
3
- Zero-Knowledge BYOK/HYOK vault SDK for React Native — the RN surface of
4
- [Kibo](https://kilimanjaro.dev/kibo).
3
+ Kibo for React Native. Encrypt and decrypt on the device with keys held in your own KMS, so the platform never sees your plaintext.
5
4
 
6
- `encrypt` / `decrypt` run entirely client-side against your own KMS. The
7
- platform never sees plaintext or unwrapped keys. All cryptography lives in the
8
- audited Rust core (`kibo-kms-rest-ffi`) compiled to wasm; this package only
9
- marshals typed input across the wasm boundary.
5
+ ## Contents
10
6
 
11
- ## Loading the core
7
+ - [Install](#install)
8
+ - [Quick start](#quick-start)
9
+ - [Load the core](#load-the-core)
10
+ - [Encrypt and decrypt](#encrypt-and-decrypt)
11
+ - [Handle errors](#handle-errors)
12
+ - [Appendix](#appendix)
13
+ - [Requirements](#requirements)
14
+ - [Methods](#methods)
15
+ - [Encrypt and decrypt fields](#encrypt-and-decrypt-fields)
16
+ - [Error codes](#error-codes)
17
+ - [Related packages](#related-packages)
12
18
 
13
- React Native cannot dynamically `import()` the wasm artifact, so the host loads
14
- the provider-matched core build and injects it once at app start:
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install @k9o/kibo-react-native
23
+ ```
24
+
25
+ Yarn works too: `yarn add @k9o/kibo-react-native`. See [requirements](#requirements).
26
+
27
+ ## Quick start
28
+
29
+ - Load the Kibo core once at app start. See [load the core](#load-the-core).
30
+ - Call `encrypt` and `decrypt`. See [encrypt and decrypt](#encrypt-and-decrypt).
31
+
32
+ This package has no cryptography of its own. It passes typed input to the Kibo core, a WebAssembly module, and returns the result.
33
+
34
+ ## Load the core
35
+
36
+ React Native cannot import the WebAssembly core on demand. Your app loads it and hands it over once with `setZkWasm`.
15
37
 
16
38
  ```ts
17
- import { setZkWasm, encrypt, decrypt } from "@k9o/kibo-react-native";
18
- import * as core from "./kibo_kms_rest_ffi.js"; // your bundled wasm build
39
+ import { setZkWasm } from "@k9o/kibo-react-native";
40
+ import * as core from "./kibo_kms_rest_ffi.js";
19
41
 
20
42
  setZkWasm(core);
43
+ ```
44
+
45
+ - The core is not shipped inside this package. Your app bundles it.
46
+ - It must expose async `zk_encrypt` and `zk_decrypt` functions (the `ZkWasm` type).
47
+ - Until `setZkWasm` runs, `encrypt` and `decrypt` fail with `KIBO_WASM_NOT_LOADED`.
48
+
49
+ ## Encrypt and decrypt
50
+
51
+ The example encrypts the title of a task. `kms_cred.secret` is a short-lived federated token you issue for your KMS.
52
+
53
+ ```ts
54
+ import { encrypt, decrypt } from "@k9o/kibo-react-native";
55
+
56
+ const kmsToken = "FEDERATED_TOKEN";
57
+ const context = [{ key: "collection", value: "tasks" }];
58
+ const title = new TextEncoder().encode("Write the README");
59
+
60
+ const sealed = await encrypt({
61
+ provider: "aws-kms",
62
+ posture: "byok",
63
+ kms_cred: { secret: kmsToken, expires_at_unix_secs: 1_800_000_000 },
64
+ key_ref: { version: 1, external_ref: "arn:aws:kms:eu-central-1:111122223333:key/example" },
65
+ provider_config: { aws_region: "eu-central-1" },
66
+ attestation_tier: "software",
67
+ encryption_context: context,
68
+ plaintext: title,
69
+ });
70
+
71
+ const opened = await decrypt({
72
+ kms_cred: { secret: kmsToken, expires_at_unix_secs: 1_800_000_000 },
73
+ provider_config: { aws_region: "eu-central-1" },
74
+ envelope: sealed.envelope,
75
+ strategy: "local_envelope",
76
+ attestation_tier: "software",
77
+ encryption_context: context,
78
+ });
79
+
80
+ console.log(new TextDecoder().decode(opened.plaintext));
81
+ ```
82
+
83
+ ```text
84
+ Write the README
85
+ ```
21
86
 
22
- const out = await encrypt(input); // KiboEncryptInput → { envelope }
23
- const back = await decrypt(input); // KiboDecryptInput → { plaintext }
87
+ - Give `decrypt` the same `strategy`, `attestation_tier` and `encryption_context` you used to encrypt.
88
+ - The returned `envelope` is opaque bytes. Store it with the encrypted record.
89
+ - All fields are listed in [encrypt and decrypt fields](#encrypt-and-decrypt-fields).
90
+
91
+ ## Handle errors
92
+
93
+ Every failure is a `KiboError` with `code`, `message` and `context`.
94
+
95
+ ```ts
96
+ import { KiboError } from "@k9o/kibo-react-native";
97
+
98
+ try {
99
+ await encrypt(input);
100
+ } catch (error) {
101
+ if (error instanceof KiboError) {
102
+ console.log(error.code);
103
+ }
104
+ }
24
105
  ```
25
106
 
26
- Errors surface as `KiboError` (`code` + `message` + `context`), preserving the
27
- core's wire codes; a posture-floor violation carries `dimension` / `requested` /
28
- `declared` in `context`.
107
+ If `setZkWasm` was skipped, this prints:
108
+
109
+ ```text
110
+ KIBO_WASM_NOT_LOADED
111
+ ```
112
+
113
+ See [error codes](#error-codes) for the full list.
114
+
115
+ ## Appendix
116
+
117
+ ### Requirements
118
+
119
+ | Requirement | Version |
120
+ |---|---|
121
+ | React | 18 or later |
122
+ | React Native | 0.74 or later |
123
+ | Kibo core (WebAssembly) | Bundled by your app |
124
+
125
+ ### Methods
126
+
127
+ | Function | What it does |
128
+ |---|---|
129
+ | `setZkWasm(core)` | Supply the Kibo core; call once at app start |
130
+ | `encrypt(input)` | Encrypt bytes with your KMS; returns `{ envelope }` |
131
+ | `decrypt(input)` | Decrypt an envelope; returns `{ plaintext }` |
132
+
133
+ ### Encrypt and decrypt fields
134
+
135
+ | Field | Used by | Meaning |
136
+ |---|---|---|
137
+ | `provider` | encrypt | `aws-kms`, `gcp-kms`, `azure-kv` or `hashicorp-vault` |
138
+ | `posture` | encrypt | `byok` or `hyok` |
139
+ | `kms_cred` | both | `{ secret, expires_at_unix_secs }` |
140
+ | `key_ref` | encrypt | `{ version, external_ref }` identifying your KMS key |
141
+ | `provider_config` | both | `{ aws_region?, vault_address? }` |
142
+ | `attestation_tier` | both | `software`, `hardware_backed` or `confidential` |
143
+ | `encryption_context` | both | List of `{ key, value }` pairs; `kibo:` keys are reserved |
144
+ | `strategy` | decrypt (optional on encrypt) | `local_envelope` or `customer_kms_oracle` |
145
+ | `oracle_mode` | encrypt, optional | `brokered` or `direct` |
146
+ | `posture_policy` | encrypt, optional | Minimum custody posture and allowed oracle modes |
147
+ | `plaintext` | encrypt | Bytes to encrypt |
148
+ | `envelope` | decrypt | Bytes returned by `encrypt` |
149
+
150
+ ### Error codes
151
+
152
+ Codes from the core are passed through unchanged.
153
+
154
+ | Code | When |
155
+ |---|---|
156
+ | `KIBO_WASM_NOT_LOADED` | `setZkWasm` has not been called |
157
+ | `K9O_CRYPTO_POSTURE_FLOOR_VIOLATION` | `posture` is below the floor in `posture_policy`; `context` has `dimension`, `requested`, `declared` |
158
+ | `UPSTREAM_KMS_ERROR` | Your own KMS rejected or failed the call |
159
+ | `KIBO_WASM_DECODE_ERROR` | The core returned something other than bytes |
160
+ | `KIBO_WASM_ERROR` | The core failed with a message that has no code |
161
+
162
+ ### Related packages
163
+
164
+ | Package | Purpose |
165
+ |---|---|
166
+ | `@k9o/gate-react-native` | End-user sign-in for React Native |
167
+ | `@k9o/kibo` | TypeScript package that also covers vault secrets and wrapped data keys |
168
+
169
+ Documentation: <https://kilimanjaro.dev>
29
170
 
30
- ## Native artifact
171
+ ## License
31
172
 
32
- The core wasm (`kibo_kms_rest_ffi_bg.wasm` + JS glue) is generated per provider
33
- by CI (`wasm-pack build --target web`) and is not vendored in this package — the
34
- host bundles it. The cross-platform packaging is the publish pipeline's
35
- responsibility — see `.gitlab/sdk-publish.yml`.
173
+ Apache-2.0 © Formelo Inc. See `LICENSE` and `NOTICE`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k9o/kibo-react-native",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "description": "Kibo Zero-Knowledge BYOK/HYOK vault SDK for React Native — client-side encrypt/decrypt against your own KMS, over the audited Rust core (kibo-kms-rest-ffi) compiled to wasm. The platform never sees plaintext.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -42,7 +42,7 @@ export interface KiboAllowedOracleModes {
42
42
  direct: boolean;
43
43
  }
44
44
 
45
- /** Project-declared crypto-posture floor (ch08 §11.3.3.4). Omit fields for the
45
+ /** Project-declared crypto-posture floor. Omit fields for the
46
46
  * most-permissive default (`platform_managed` floor + both oracle modes). */
47
47
  export interface KiboPosturePolicy {
48
48
  min_custody_posture?: KiboMinPosture;