@k9o/kibo-react-native 0.1.0 → 1.1.1

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,179 @@
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
+ - [Links](#links)
8
+ - [Install](#install)
9
+ - [Quick start](#quick-start)
10
+ - [Load the core](#load-the-core)
11
+ - [Encrypt and decrypt](#encrypt-and-decrypt)
12
+ - [Handle errors](#handle-errors)
13
+ - [Appendix](#appendix)
12
14
 
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:
15
+ ## Links
16
+
17
+ - Website: <https://kilimanjaro.dev>
18
+ - Documentation / Developer Hub: <https://docs.kilimanjaro.dev>
19
+ - Platform API: <https://api.k9o.io>
20
+ - Platform Console: <https://console.k9o.io>
21
+ - [Requirements](#requirements)
22
+ - [Methods](#methods)
23
+ - [Encrypt and decrypt fields](#encrypt-and-decrypt-fields)
24
+ - [Error codes](#error-codes)
25
+ - [Related packages](#related-packages)
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm install @k9o/kibo-react-native
31
+ ```
32
+
33
+ Yarn works too: `yarn add @k9o/kibo-react-native`. See [requirements](#requirements).
34
+
35
+ ## Quick start
36
+
37
+ - Load the Kibo core once at app start. See [load the core](#load-the-core).
38
+ - Call `encrypt` and `decrypt`. See [encrypt and decrypt](#encrypt-and-decrypt).
39
+
40
+ This package has no cryptography of its own. It passes typed input to the Kibo core, a WebAssembly module, and returns the result.
41
+
42
+ ## Load the core
43
+
44
+ React Native cannot import the WebAssembly core on demand. Your app loads it and hands it over once with `setZkWasm`.
15
45
 
16
46
  ```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
47
+ import { setZkWasm } from "@k9o/kibo-react-native";
48
+ import * as core from "./kibo_kms_rest_ffi.js";
19
49
 
20
50
  setZkWasm(core);
51
+ ```
21
52
 
22
- const out = await encrypt(input); // KiboEncryptInput → { envelope }
23
- const back = await decrypt(input); // KiboDecryptInput → { plaintext }
53
+ - The core is not shipped inside this package. Your app bundles it.
54
+ - It must expose async `zk_encrypt` and `zk_decrypt` functions (the `ZkWasm` type).
55
+ - Until `setZkWasm` runs, `encrypt` and `decrypt` fail with `KIBO_WASM_NOT_LOADED`.
56
+
57
+ ## Encrypt and decrypt
58
+
59
+ The example encrypts the title of a task. `kms_cred.secret` is a short-lived federated token you issue for your KMS.
60
+
61
+ ```ts
62
+ import { encrypt, decrypt } from "@k9o/kibo-react-native";
63
+
64
+ const kmsToken = "FEDERATED_TOKEN";
65
+ const context = [{ key: "collection", value: "tasks" }];
66
+ const title = new TextEncoder().encode("Write the README");
67
+
68
+ const sealed = await encrypt({
69
+ provider: "aws-kms",
70
+ posture: "byok",
71
+ kms_cred: { secret: kmsToken, expires_at_unix_secs: 1_800_000_000 },
72
+ key_ref: { version: 1, external_ref: "arn:aws:kms:eu-central-1:111122223333:key/example" },
73
+ provider_config: { aws_region: "eu-central-1" },
74
+ attestation_tier: "software",
75
+ encryption_context: context,
76
+ plaintext: title,
77
+ });
78
+
79
+ const opened = await decrypt({
80
+ kms_cred: { secret: kmsToken, expires_at_unix_secs: 1_800_000_000 },
81
+ provider_config: { aws_region: "eu-central-1" },
82
+ envelope: sealed.envelope,
83
+ strategy: "local_envelope",
84
+ attestation_tier: "software",
85
+ encryption_context: context,
86
+ });
87
+
88
+ console.log(new TextDecoder().decode(opened.plaintext));
24
89
  ```
25
90
 
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`.
91
+ ```text
92
+ Write the README
93
+ ```
94
+
95
+ - Give `decrypt` the same `strategy`, `attestation_tier` and `encryption_context` you used to encrypt.
96
+ - The returned `envelope` is opaque bytes. Store it with the encrypted record.
97
+ - All fields are listed in [encrypt and decrypt fields](#encrypt-and-decrypt-fields).
98
+
99
+ ## Handle errors
100
+
101
+ Every failure is a `KiboError` with `code`, `message` and `context`.
102
+
103
+ ```ts
104
+ import { KiboError } from "@k9o/kibo-react-native";
105
+
106
+ try {
107
+ await encrypt(input);
108
+ } catch (error) {
109
+ if (error instanceof KiboError) {
110
+ console.log(error.code);
111
+ }
112
+ }
113
+ ```
114
+
115
+ If `setZkWasm` was skipped, this prints:
116
+
117
+ ```text
118
+ KIBO_WASM_NOT_LOADED
119
+ ```
120
+
121
+ See [error codes](#error-codes) for the full list.
122
+
123
+ ## Appendix
124
+
125
+ ### Requirements
126
+
127
+ | Requirement | Version |
128
+ |---|---|
129
+ | React | 18 or later |
130
+ | React Native | 0.74 or later |
131
+ | Kibo core (WebAssembly) | Bundled by your app |
132
+
133
+ ### Methods
134
+
135
+ | Function | What it does |
136
+ |---|---|
137
+ | `setZkWasm(core)` | Supply the Kibo core; call once at app start |
138
+ | `encrypt(input)` | Encrypt bytes with your KMS; returns `{ envelope }` |
139
+ | `decrypt(input)` | Decrypt an envelope; returns `{ plaintext }` |
140
+
141
+ ### Encrypt and decrypt fields
142
+
143
+ | Field | Used by | Meaning |
144
+ |---|---|---|
145
+ | `provider` | encrypt | `aws-kms`, `gcp-kms`, `azure-kv` or `hashicorp-vault` |
146
+ | `posture` | encrypt | `byok` or `hyok` |
147
+ | `kms_cred` | both | `{ secret, expires_at_unix_secs }` |
148
+ | `key_ref` | encrypt | `{ version, external_ref }` identifying your KMS key |
149
+ | `provider_config` | both | `{ aws_region?, vault_address? }` |
150
+ | `attestation_tier` | both | `software`, `hardware_backed` or `confidential` |
151
+ | `encryption_context` | both | List of `{ key, value }` pairs; `kibo:` keys are reserved |
152
+ | `strategy` | decrypt (optional on encrypt) | `local_envelope` or `customer_kms_oracle` |
153
+ | `oracle_mode` | encrypt, optional | `brokered` or `direct` |
154
+ | `posture_policy` | encrypt, optional | Minimum custody posture and allowed oracle modes |
155
+ | `plaintext` | encrypt | Bytes to encrypt |
156
+ | `envelope` | decrypt | Bytes returned by `encrypt` |
157
+
158
+ ### Error codes
159
+
160
+ Codes from the core are passed through unchanged.
161
+
162
+ | Code | When |
163
+ |---|---|
164
+ | `KIBO_WASM_NOT_LOADED` | `setZkWasm` has not been called |
165
+ | `K9O_CRYPTO_POSTURE_FLOOR_VIOLATION` | `posture` is below the floor in `posture_policy`; `context` has `dimension`, `requested`, `declared` |
166
+ | `UPSTREAM_KMS_ERROR` | Your own KMS rejected or failed the call |
167
+ | `KIBO_WASM_DECODE_ERROR` | The core returned something other than bytes |
168
+ | `KIBO_WASM_ERROR` | The core failed with a message that has no code |
169
+
170
+ ### Related packages
171
+
172
+ | Package | Purpose |
173
+ |---|---|
174
+ | `@k9o/gate-react-native` | End-user sign-in for React Native |
175
+ | `@k9o/kibo` | TypeScript package that also covers vault secrets and wrapped data keys |
29
176
 
30
- ## Native artifact
177
+ ## License
31
178
 
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`.
179
+ 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.1",
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",
@@ -16,7 +16,7 @@
16
16
  "type": "git",
17
17
  "url": "https://github.com/k9o-dev/k9o-kibo-react-native.git"
18
18
  },
19
- "homepage": "https://kilimanjaro.dev/sdks/react-native",
19
+ "homepage": "https://kilimanjaro.dev",
20
20
  "keywords": ["kilimanjaro", "kibo", "byok", "hyok", "encryption", "react-native"],
21
21
  "license": "Apache-2.0",
22
22
  "publishConfig": {
@@ -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;