@datacules/agent-identity-store-dynamic 0.2.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.
Files changed (2) hide show
  1. package/README.md +81 -0
  2. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # `@datacules/agent-identity-store-dynamic`
2
+
3
+ Just-in-time credential provisioning for [`@datacules/agent-identity`](../../core). Credentials don't exist until the agent requests them — minted on demand with a short TTL, revoked automatically by the upstream system.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @datacules/agent-identity-store-dynamic
9
+ ```
10
+
11
+ ## Why JIT?
12
+
13
+ With static credential stores, long-lived secrets sit at rest — if the store is compromised, every credential in it is exposed. With JIT provisioning, there are no stored secrets: the store calls your vault on every resolution and gets back a short-lived lease. After the TTL (15–60 minutes) the upstream system revokes the secret automatically. The blast radius of any store compromise collapses to a single active session at most.
14
+
15
+ ## Usage
16
+
17
+ ### Vault dynamic secrets
18
+
19
+ ```typescript
20
+ import { DynamicCredentialStore, VaultDynamicProvisioner } from '@datacules/agent-identity-store-dynamic';
21
+ import { createRouterFromStore } from '@datacules/agent-identity';
22
+
23
+ const store = new DynamicCredentialStore({
24
+ provisioner: new VaultDynamicProvisioner({
25
+ vaultAddr: 'http://vault:8200',
26
+ token: process.env.VAULT_TOKEN!,
27
+ mount: 'database',
28
+ role: 'crm-readonly',
29
+ ttl: '30m',
30
+ }),
31
+ });
32
+
33
+ const router = createRouterFromStore(store, rules, logger);
34
+ const resolved = await router.resolveAsync(ctx);
35
+ // resolved.ref → Vault lease ID — use this to fetch the actual secret server-side
36
+ // resolved.expiresAt → when the lease expires
37
+ ```
38
+
39
+ ### AWS IAM Roles Anywhere
40
+
41
+ ```typescript
42
+ import { DynamicCredentialStore, AwsRolesAnywhereProvisioner } from '@datacules/agent-identity-store-dynamic';
43
+
44
+ const store = new DynamicCredentialStore({
45
+ provisioner: new AwsRolesAnywhereProvisioner({
46
+ profileArn: 'arn:aws:rolesanywhere:us-east-1:...',
47
+ roleArn: 'arn:aws:iam::...:role/agent-role',
48
+ trustAnchorArn: 'arn:aws:rolesanywhere:us-east-1:...',
49
+ region: 'us-east-1',
50
+ durationSeconds: 3600,
51
+ }),
52
+ });
53
+ ```
54
+
55
+ ### Custom provisioner
56
+
57
+ ```typescript
58
+ import type { DynamicProvisioner, ProvisionedSecret } from '@datacules/agent-identity-store-dynamic';
59
+
60
+ class MyProvisioner implements DynamicProvisioner {
61
+ id = 'my-vault';
62
+
63
+ async provision(ref: string): Promise<ProvisionedSecret> {
64
+ // Call your secret management system here
65
+ const { leaseId, ttlSeconds, secret } = await myVault.issue(ref);
66
+ return {
67
+ leaseId,
68
+ expiresAt: new Date(Date.now() + ttlSeconds * 1000).toISOString(),
69
+ secret,
70
+ };
71
+ }
72
+
73
+ async revoke(leaseId: string): Promise<void> {
74
+ await myVault.revoke(leaseId);
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Caching
80
+
81
+ By default, unexpired leases are cached in memory and reused until 60 seconds before expiry (configurable via `renewBeforeExpireSeconds`). Set `cache: false` to provision a fresh lease on every resolution.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@datacules/agent-identity-store-dynamic",
3
+ "version": "0.2.1",
4
+ "private": false,
5
+ "description": "Just-in-time credential provisioning store for @datacules/agent-identity — mints short-lived secrets on demand via Vault dynamic secrets or AWS IAM Roles Anywhere",
6
+ "author": "Datacules LLC",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/hvrcharon1/agent-identity.git",
11
+ "directory": "packages/stores/dynamic"
12
+ },
13
+ "main": "./dist/cjs/index.js",
14
+ "module": "./dist/esm/index.js",
15
+ "types": "./dist/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/esm/index.js",
19
+ "require": "./dist/cjs/index.js",
20
+ "types": "./dist/types/index.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.build.json",
29
+ "type-check": "tsc --noEmit",
30
+ "lint": "eslint src --ext .ts"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20",
34
+ "typescript": "^5"
35
+ },
36
+ "peerDependencies": {
37
+ "@datacules/agent-identity": "^0.1.0"
38
+ }
39
+ }