@the-ai-company/cbio-node-runtime 0.31.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/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/agent/agent.d.ts +234 -0
- package/dist/agent/agent.js +565 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/audit/ActivityLog.d.ts +25 -0
- package/dist/audit/ActivityLog.js +66 -0
- package/dist/audit/ActivityLog.js.map +1 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/http/authClient.d.ts +26 -0
- package/dist/http/authClient.js +132 -0
- package/dist/http/authClient.js.map +1 -0
- package/dist/http/localAuthProxy.d.ts +33 -0
- package/dist/http/localAuthProxy.js +93 -0
- package/dist/http/localAuthProxy.js.map +1 -0
- package/dist/http/secretAcquisition.d.ts +54 -0
- package/dist/http/secretAcquisition.js +177 -0
- package/dist/http/secretAcquisition.js.map +1 -0
- package/dist/protocol/childSecretNaming.d.ts +7 -0
- package/dist/protocol/childSecretNaming.js +12 -0
- package/dist/protocol/childSecretNaming.js.map +1 -0
- package/dist/protocol/crypto.d.ts +23 -0
- package/dist/protocol/crypto.js +37 -0
- package/dist/protocol/crypto.js.map +1 -0
- package/dist/protocol/identity.d.ts +8 -0
- package/dist/protocol/identity.js +16 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.js +11 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/sealed/index.d.ts +6 -0
- package/dist/sealed/index.js +6 -0
- package/dist/sealed/index.js.map +1 -0
- package/dist/sealed/seal.d.ts +19 -0
- package/dist/sealed/seal.js +56 -0
- package/dist/sealed/seal.js.map +1 -0
- package/dist/storage/fs.d.ts +16 -0
- package/dist/storage/fs.js +68 -0
- package/dist/storage/fs.js.map +1 -0
- package/dist/storage/memory.d.ts +11 -0
- package/dist/storage/memory.js +19 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/storage/provider.d.ts +12 -0
- package/dist/storage/provider.js +6 -0
- package/dist/storage/provider.js.map +1 -0
- package/dist/vault/secretPolicy.d.ts +3 -0
- package/dist/vault/secretPolicy.js +14 -0
- package/dist/vault/secretPolicy.js.map +1 -0
- package/dist/vault/vault.d.ts +91 -0
- package/dist/vault/vault.js +534 -0
- package/dist/vault/vault.js.map +1 -0
- package/docs/ARCHITECTURE.md +100 -0
- package/docs/REFERENCE.md +184 -0
- package/docs/TODO-multi-vault.md +29 -0
- package/docs/WORKS_WITH_CUSTOM_FETCH.md +196 -0
- package/docs/es/README.md +27 -0
- package/docs/fr/README.md +27 -0
- package/docs/ja/README.md +27 -0
- package/docs/ko/README.md +27 -0
- package/docs/pt/README.md +27 -0
- package/docs/spec/runtime/README.md +27 -0
- package/docs/spec/runtime/activity-log.md +67 -0
- package/docs/spec/runtime/managed-agent-record.md +52 -0
- package/docs/spec/runtime/merge-rules.md +52 -0
- package/docs/spec/runtime/secret-origin-policy.md +46 -0
- package/docs/zh/README.md +27 -0
- package/examples/minimal.ts +13 -0
- package/package.json +57 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Activity Log
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Defines the local audit trail for vault-authenticated runtime actions.
|
|
6
|
+
|
|
7
|
+
This log is runtime-local. It is not a protocol object and is not required to be shared across peers.
|
|
8
|
+
|
|
9
|
+
## Entry Shape
|
|
10
|
+
|
|
11
|
+
Each entry must contain:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"ts": 0,
|
|
16
|
+
"action": "fetchWithAuth",
|
|
17
|
+
"secretName": "string",
|
|
18
|
+
"url": "string",
|
|
19
|
+
"method": "GET",
|
|
20
|
+
"success": true
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Required fields:
|
|
25
|
+
- `ts`: event timestamp in Unix milliseconds
|
|
26
|
+
- `action`: runtime action name
|
|
27
|
+
- `secretName`: vault secret involved
|
|
28
|
+
- `url`: request URL
|
|
29
|
+
- `method`: HTTP method
|
|
30
|
+
- `success`: whether the action succeeded
|
|
31
|
+
|
|
32
|
+
Optional fields:
|
|
33
|
+
- `error`: failure message when `success` is `false`
|
|
34
|
+
|
|
35
|
+
## Defined Actions
|
|
36
|
+
|
|
37
|
+
Current action names:
|
|
38
|
+
- `fetchWithAuth`
|
|
39
|
+
- `fetchJsonAndAddSecret`
|
|
40
|
+
- `fetchJsonAndUpdateSecret`
|
|
41
|
+
|
|
42
|
+
## Required Semantics
|
|
43
|
+
|
|
44
|
+
1. `fetchWithAuth` success and failure attempts must append an activity entry.
|
|
45
|
+
2. JSON secret acquisition and rotation success and failure attempts must append an activity entry.
|
|
46
|
+
3. Direct admin secret mutation such as `addSecret` is not part of this audit stream.
|
|
47
|
+
|
|
48
|
+
## Failure Semantics
|
|
49
|
+
|
|
50
|
+
If activity log persistence fails:
|
|
51
|
+
|
|
52
|
+
- `fetchWithAuth` may still throw its primary runtime error
|
|
53
|
+
- `fetchJsonAndAddSecret` and `fetchJsonAndUpdateSecret` must return their normal `FetchResult` shape
|
|
54
|
+
- those returned results must set `activityLogWriteFailed: true`
|
|
55
|
+
|
|
56
|
+
The primary operation outcome must not be silently rewritten into a different success/failure class solely because audit persistence failed.
|
|
57
|
+
|
|
58
|
+
## Compatibility
|
|
59
|
+
|
|
60
|
+
- Action names are part of the runtime contract.
|
|
61
|
+
- Writers may append extra fields, but readers must tolerate unknown fields.
|
|
62
|
+
|
|
63
|
+
## Non-Goals
|
|
64
|
+
|
|
65
|
+
- Defining centralized logging
|
|
66
|
+
- Defining protocol-visible governance audit records
|
|
67
|
+
- Defining retention policy for local log files
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Managed Agent Record
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Defines the persisted local record format used by a parent identity to store a managed agent identity in its own vault.
|
|
6
|
+
|
|
7
|
+
This is a runtime record, not a protocol object.
|
|
8
|
+
|
|
9
|
+
## Record Shape
|
|
10
|
+
|
|
11
|
+
The persisted JSON object must contain:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"agentId": "string",
|
|
16
|
+
"publicKey": "string",
|
|
17
|
+
"privateKey": "string",
|
|
18
|
+
"issuedIdentity": {},
|
|
19
|
+
"storageKey": "string"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Required fields:
|
|
24
|
+
- `agentId`: the derived root agent id for `publicKey`
|
|
25
|
+
- `publicKey`: the managed agent public key
|
|
26
|
+
- `privateKey`: the managed agent private key
|
|
27
|
+
- `issuedIdentity`: the signed `IssuedAgentIdentity` protocol object for the managed agent
|
|
28
|
+
|
|
29
|
+
Optional fields:
|
|
30
|
+
- `storageKey`: the vault storage key where the managed agent's vault data is or should be persisted. When present, loaders must use it to restore the same vault binding used at issuance; when absent, loaders may use an implementation-defined default (e.g. derived from `publicKey`).
|
|
31
|
+
|
|
32
|
+
## Required Semantics
|
|
33
|
+
|
|
34
|
+
1. `issuedIdentity.agent.public_key` must equal `publicKey`.
|
|
35
|
+
2. `issuedIdentity.agent.agent_id` must equal `agentId`.
|
|
36
|
+
3. `privateKey` must derive to `publicKey`.
|
|
37
|
+
4. The record is stored in the authority vault under an authority-chosen record key.
|
|
38
|
+
5. Loading a managed agent from this record must fail if the managed agent has been revoked by the authority.
|
|
39
|
+
6. When `storageKey` is present, loaders must prefer it for vault binding; writers may depend on this for correctness.
|
|
40
|
+
|
|
41
|
+
## Compatibility
|
|
42
|
+
|
|
43
|
+
- Field names are part of the runtime contract.
|
|
44
|
+
- `storageKey` is a defined optional field; writers may depend on readers honoring it when present.
|
|
45
|
+
- Other additional fields may be ignored by readers, and writers should not depend on them for correctness.
|
|
46
|
+
- A future versioned schema must use an explicit version field instead of changing meanings silently.
|
|
47
|
+
|
|
48
|
+
## Non-Goals
|
|
49
|
+
|
|
50
|
+
- Defining the `IssuedAgentIdentity` protocol object itself
|
|
51
|
+
- Defining how the vault encrypts or persists this record
|
|
52
|
+
- Defining language-specific API shapes such as `issueManagedAgent(...)`
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Merge Rules
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Defines when one runtime vault may merge secrets from another vault representing the same root identity.
|
|
6
|
+
|
|
7
|
+
## Preconditions
|
|
8
|
+
|
|
9
|
+
1. Both vaults must belong to the same root identity.
|
|
10
|
+
2. If root identities differ, the merge must fail with `MERGE_IDENTITY_MISMATCH`.
|
|
11
|
+
|
|
12
|
+
## Conflict Modes
|
|
13
|
+
|
|
14
|
+
Supported conflict modes:
|
|
15
|
+
- `abort`
|
|
16
|
+
- `skip`
|
|
17
|
+
- `overwrite`
|
|
18
|
+
|
|
19
|
+
### `abort`
|
|
20
|
+
|
|
21
|
+
- If any incoming secret name already exists in the target vault, the merge must fail.
|
|
22
|
+
- No partial merge may be committed.
|
|
23
|
+
|
|
24
|
+
### `skip`
|
|
25
|
+
|
|
26
|
+
- Existing target secrets keep their current value.
|
|
27
|
+
- Incoming secrets with new names are merged.
|
|
28
|
+
|
|
29
|
+
### `overwrite`
|
|
30
|
+
|
|
31
|
+
- Incoming secrets replace target secrets with the same name.
|
|
32
|
+
- Incoming secrets with new names are merged.
|
|
33
|
+
|
|
34
|
+
## Required Semantics
|
|
35
|
+
|
|
36
|
+
1. Merge identity matching is determined from the vault owner identity, not from caller trust.
|
|
37
|
+
2. Secret names are the merge keys.
|
|
38
|
+
3. Secret values and their associated policy metadata must move together.
|
|
39
|
+
4. Merge behavior must be deterministic for a given source vault, target vault, and conflict mode.
|
|
40
|
+
|
|
41
|
+
## Result Shape
|
|
42
|
+
|
|
43
|
+
Implementations may expose result objects differently, but they must be able to report at least:
|
|
44
|
+
- added secret names
|
|
45
|
+
- skipped secret names
|
|
46
|
+
- overwritten secret names
|
|
47
|
+
|
|
48
|
+
## Non-Goals
|
|
49
|
+
|
|
50
|
+
- Defining a protocol object for merges
|
|
51
|
+
- Defining cross-process locking
|
|
52
|
+
- Defining transport/import mechanisms for moving sealed vault data
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Secret Origin Policy
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Defines the runtime policy for secrets acquired from remote endpoints and for later rotation of those secrets.
|
|
6
|
+
|
|
7
|
+
## URL Acceptance
|
|
8
|
+
|
|
9
|
+
An acquisition or rotation URL is allowed only if:
|
|
10
|
+
- it uses `https:`, or
|
|
11
|
+
- it uses `http:` with a loopback host for local development
|
|
12
|
+
|
|
13
|
+
Loopback hosts include:
|
|
14
|
+
- `localhost`
|
|
15
|
+
- `127.0.0.1`
|
|
16
|
+
- `[::1]`
|
|
17
|
+
|
|
18
|
+
Non-loopback plain HTTP must be rejected.
|
|
19
|
+
|
|
20
|
+
## Acquisition Semantics
|
|
21
|
+
|
|
22
|
+
When a secret is fetched from a remote endpoint and stored:
|
|
23
|
+
|
|
24
|
+
1. If the caller does not provide `allowedOrigins`, the stored secret policy must default to the fetch URL origin.
|
|
25
|
+
2. If the requested secret name already exists, the runtime must allocate a unique name by suffixing `_N` where `N` starts at `1`.
|
|
26
|
+
3. The returned payload must not leak the extracted secret value in cleartext.
|
|
27
|
+
|
|
28
|
+
## Rotation Semantics
|
|
29
|
+
|
|
30
|
+
When a secret is rotated from a remote endpoint:
|
|
31
|
+
|
|
32
|
+
1. The rotation source origin must be allowed by the existing secret policy.
|
|
33
|
+
2. If no origin policy exists for the secret, rotation must fail with `SECRET_POLICY_REQUIRED`.
|
|
34
|
+
3. If the fetch origin is not allowed, rotation must fail with `SECRET_SOURCE_ORIGIN_MISMATCH`.
|
|
35
|
+
4. A failed rotation must not replace the existing active secret value.
|
|
36
|
+
|
|
37
|
+
## Normalization
|
|
38
|
+
|
|
39
|
+
- Origin comparison is performed on normalized origin strings.
|
|
40
|
+
- Path, query, and fragment are not part of the policy match.
|
|
41
|
+
|
|
42
|
+
## Non-Goals
|
|
43
|
+
|
|
44
|
+
- Defining provider-specific API behavior
|
|
45
|
+
- Defining generic HTTP request libraries
|
|
46
|
+
- Defining how secret values are used after storage
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# cbio Node Runtime
|
|
2
|
+
|
|
3
|
+
cbio 身份与凭证保险库的 Node.js 运行时。仅库,无 CLI 或 TUI。
|
|
4
|
+
|
|
5
|
+
从主入口导入并使用 `CbioIdentity`、`CbioAgent`。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @the-ai-company/cbio-node-runtime
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { CbioIdentity, generateIdentityKeys } from '@the-ai-company/cbio-node-runtime';
|
|
17
|
+
|
|
18
|
+
const keys = generateIdentityKeys();
|
|
19
|
+
const identity = await CbioIdentity.load({ privateKey: keys.privateKey });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 构建
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm run build
|
|
26
|
+
npm run test
|
|
27
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CbioIdentity } from '@the-ai-company/agent-identity-sdk';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const privateKey = process.env.AGENT_PRIV_KEY!;
|
|
5
|
+
const identity = await CbioIdentity.load({ privateKey });
|
|
6
|
+
const agent = identity.getAgent();
|
|
7
|
+
|
|
8
|
+
// Use the agent to call external services with automatic authentication
|
|
9
|
+
const response = await agent.fetchWithAuth('my-service', 'https://api.example.com/data');
|
|
10
|
+
console.log(await response.json());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
main().catch(console.error);
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@the-ai-company/cbio-node-runtime",
|
|
3
|
+
"version": "0.31.0",
|
|
4
|
+
"description": "Node.js runtime for cbio identity and credential vault. Library only, no CLI or TUI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/runtime/index.js",
|
|
7
|
+
"module": "./dist/runtime/index.js",
|
|
8
|
+
"types": "./dist/runtime/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"docs/",
|
|
12
|
+
"examples/",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/runtime/index.js",
|
|
19
|
+
"types": "./dist/runtime/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./protocol": {
|
|
22
|
+
"import": "./dist/protocol/identity.js",
|
|
23
|
+
"types": "./dist/protocol/identity.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./sealed": {
|
|
26
|
+
"import": "./dist/sealed/index.js",
|
|
27
|
+
"types": "./dist/sealed/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@the-ai-company/cbio-protocol": "^1.0.3"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node ./scripts/clean-dist.mjs && tsc",
|
|
35
|
+
"prepare": "npm run build",
|
|
36
|
+
"test": "npm run build && npm run test:acceptance",
|
|
37
|
+
"test:acceptance": "node tests/runtime/derivation.js && node tests/runtime/errors.js && node tests/runtime/hardened_vault.js && node tests/runtime/isolation_local.js && node tests/runtime/managed_agent_identity.js && node tests/runtime/merge_security_local.js && node tests/runtime/recursive_cbio.js && node tests/runtime/register_child.js && node tests/runtime/transparency.js && node tests/runtime/vault_resilience.js && node tests/runtime/activity_log.js && node tests/runtime/secret_rotation_policy.js && node tests/runtime/local_auth_proxy.js && node tests/storage/adaptability.js && node tests/runtime/autosave.js"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"claw-biometric",
|
|
41
|
+
"agent",
|
|
42
|
+
"identity",
|
|
43
|
+
"vault",
|
|
44
|
+
"secrets",
|
|
45
|
+
"node-runtime"
|
|
46
|
+
],
|
|
47
|
+
"author": "The AI Company",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": "https://github.com/TheAICompany/cbio-node-runtime",
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.0.0",
|
|
52
|
+
"typescript": "^5.0.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|