@vess-id/ai-identity 0.0.0-dev-20260902121045

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 (173) hide show
  1. package/README.md +265 -0
  2. package/dist/agent/agent-did-manager.d.ts +97 -0
  3. package/dist/agent/agent-did-manager.d.ts.map +1 -0
  4. package/dist/auth/auth-provider.d.ts +51 -0
  5. package/dist/auth/auth-provider.d.ts.map +1 -0
  6. package/dist/auth/index.d.ts +2 -0
  7. package/dist/auth/index.d.ts.map +1 -0
  8. package/dist/client.d.ts +63 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/config/index.d.ts +84 -0
  11. package/dist/config/index.d.ts.map +1 -0
  12. package/dist/constraint/constraint-evaluator.d.ts +103 -0
  13. package/dist/constraint/constraint-evaluator.d.ts.map +1 -0
  14. package/dist/constraint/index.d.ts +5 -0
  15. package/dist/constraint/index.d.ts.map +1 -0
  16. package/dist/did/agent.d.ts +58 -0
  17. package/dist/did/agent.d.ts.map +1 -0
  18. package/dist/did/did-utils.d.ts +82 -0
  19. package/dist/did/did-utils.d.ts.map +1 -0
  20. package/dist/did/key-manager.d.ts +19 -0
  21. package/dist/did/key-manager.d.ts.map +1 -0
  22. package/dist/gateway/gateway-client.d.ts +103 -0
  23. package/dist/gateway/gateway-client.d.ts.map +1 -0
  24. package/dist/gateway/index.d.ts +2 -0
  25. package/dist/gateway/index.d.ts.map +1 -0
  26. package/dist/grant/grant-manager.d.ts +140 -0
  27. package/dist/grant/grant-manager.d.ts.map +1 -0
  28. package/dist/grant/index.d.ts +2 -0
  29. package/dist/grant/index.d.ts.map +1 -0
  30. package/dist/identity/device-enroll-manager.d.ts +117 -0
  31. package/dist/identity/device-enroll-manager.d.ts.map +1 -0
  32. package/dist/identity/user-identity-manager.d.ts +123 -0
  33. package/dist/identity/user-identity-manager.d.ts.map +1 -0
  34. package/dist/identity/user-key-pair-manager.d.ts +22 -0
  35. package/dist/identity/user-key-pair-manager.d.ts.map +1 -0
  36. package/dist/index.d.mts +42685 -0
  37. package/dist/index.d.ts +57 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +19534 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/index.mjs +19347 -0
  42. package/dist/index.mjs.map +1 -0
  43. package/dist/internal-signature/canonical.d.ts +80 -0
  44. package/dist/internal-signature/canonical.d.ts.map +1 -0
  45. package/dist/internal-signature/index.d.ts +17 -0
  46. package/dist/internal-signature/index.d.ts.map +1 -0
  47. package/dist/internal-signature/signer.d.ts +76 -0
  48. package/dist/internal-signature/signer.d.ts.map +1 -0
  49. package/dist/policy/cedar-engine.d.ts +334 -0
  50. package/dist/policy/cedar-engine.d.ts.map +1 -0
  51. package/dist/policy/cedar-entities.d.ts +59 -0
  52. package/dist/policy/cedar-entities.d.ts.map +1 -0
  53. package/dist/policy/decision.d.ts +46 -0
  54. package/dist/policy/decision.d.ts.map +1 -0
  55. package/dist/policy/index.d.ts +15 -0
  56. package/dist/policy/index.d.ts.map +1 -0
  57. package/dist/registry/access-orchestrator.d.ts +184 -0
  58. package/dist/registry/access-orchestrator.d.ts.map +1 -0
  59. package/dist/registry/action-aliases.d.ts +37 -0
  60. package/dist/registry/action-aliases.d.ts.map +1 -0
  61. package/dist/registry/action-input-validator.d.ts +19 -0
  62. package/dist/registry/action-input-validator.d.ts.map +1 -0
  63. package/dist/registry/action-normalizer.d.ts +47 -0
  64. package/dist/registry/action-normalizer.d.ts.map +1 -0
  65. package/dist/registry/action-registry-json.d.ts +35897 -0
  66. package/dist/registry/action-registry-json.d.ts.map +1 -0
  67. package/dist/registry/action-registry.d.ts +101 -0
  68. package/dist/registry/action-registry.d.ts.map +1 -0
  69. package/dist/registry/action-risk.d.ts +109 -0
  70. package/dist/registry/action-risk.d.ts.map +1 -0
  71. package/dist/registry/action-summary.d.ts +16 -0
  72. package/dist/registry/action-summary.d.ts.map +1 -0
  73. package/dist/registry/index.d.ts +14 -0
  74. package/dist/registry/index.d.ts.map +1 -0
  75. package/dist/registry/providers.d.ts +32 -0
  76. package/dist/registry/providers.d.ts.map +1 -0
  77. package/dist/registry/reauth-constants.d.ts +56 -0
  78. package/dist/registry/reauth-constants.d.ts.map +1 -0
  79. package/dist/registry/resource-type-labels.d.ts +15 -0
  80. package/dist/registry/resource-type-labels.d.ts.map +1 -0
  81. package/dist/registry/resource-types.d.ts +47 -0
  82. package/dist/registry/resource-types.d.ts.map +1 -0
  83. package/dist/resolver/approval-time-resolution.d.ts +72 -0
  84. package/dist/resolver/approval-time-resolution.d.ts.map +1 -0
  85. package/dist/resolver/canonical-resource-id.d.ts +37 -0
  86. package/dist/resolver/canonical-resource-id.d.ts.map +1 -0
  87. package/dist/resolver/compare-resource-id.d.ts +37 -0
  88. package/dist/resolver/compare-resource-id.d.ts.map +1 -0
  89. package/dist/resolver/salient-digest.d.ts +48 -0
  90. package/dist/resolver/salient-digest.d.ts.map +1 -0
  91. package/dist/resolver/target-resolver.d.ts +28 -0
  92. package/dist/resolver/target-resolver.d.ts.map +1 -0
  93. package/dist/state/index.d.ts +3 -0
  94. package/dist/state/index.d.ts.map +1 -0
  95. package/dist/state/json-state-store.d.ts +24 -0
  96. package/dist/state/json-state-store.d.ts.map +1 -0
  97. package/dist/state/state-store.interface.d.ts +37 -0
  98. package/dist/state/state-store.interface.d.ts.map +1 -0
  99. package/dist/storage/filesystem-key-storage.d.ts +16 -0
  100. package/dist/storage/filesystem-key-storage.d.ts.map +1 -0
  101. package/dist/storage/index.d.ts +4 -0
  102. package/dist/storage/index.d.ts.map +1 -0
  103. package/dist/storage/key-storage.interface.d.ts +42 -0
  104. package/dist/storage/key-storage.interface.d.ts.map +1 -0
  105. package/dist/storage/memory-key-storage.d.ts +17 -0
  106. package/dist/storage/memory-key-storage.d.ts.map +1 -0
  107. package/dist/tool/tool-manager.d.ts +44 -0
  108. package/dist/tool/tool-manager.d.ts.map +1 -0
  109. package/dist/types/agent.d.ts +139 -0
  110. package/dist/types/agent.d.ts.map +1 -0
  111. package/dist/types/audit.d.ts +23 -0
  112. package/dist/types/audit.d.ts.map +1 -0
  113. package/dist/types/cedar-policy.d.ts +60 -0
  114. package/dist/types/cedar-policy.d.ts.map +1 -0
  115. package/dist/types/connector-plugin.d.ts +252 -0
  116. package/dist/types/connector-plugin.d.ts.map +1 -0
  117. package/dist/types/connectors.d.ts +39 -0
  118. package/dist/types/connectors.d.ts.map +1 -0
  119. package/dist/types/context.d.ts +152 -0
  120. package/dist/types/context.d.ts.map +1 -0
  121. package/dist/types/did.d.ts +18 -0
  122. package/dist/types/did.d.ts.map +1 -0
  123. package/dist/types/errors.d.ts +24 -0
  124. package/dist/types/errors.d.ts.map +1 -0
  125. package/dist/types/grant.d.ts +522 -0
  126. package/dist/types/grant.d.ts.map +1 -0
  127. package/dist/types/index.d.ts +22 -0
  128. package/dist/types/index.d.ts.map +1 -0
  129. package/dist/types/intent.d.ts +133 -0
  130. package/dist/types/intent.d.ts.map +1 -0
  131. package/dist/types/invitation.d.ts +97 -0
  132. package/dist/types/invitation.d.ts.map +1 -0
  133. package/dist/types/jira.d.ts +348 -0
  134. package/dist/types/jira.d.ts.map +1 -0
  135. package/dist/types/oauth.d.ts +72 -0
  136. package/dist/types/oauth.d.ts.map +1 -0
  137. package/dist/types/organization.d.ts +77 -0
  138. package/dist/types/organization.d.ts.map +1 -0
  139. package/dist/types/permission-mode.d.ts +138 -0
  140. package/dist/types/permission-mode.d.ts.map +1 -0
  141. package/dist/types/permission-vc.d.ts +800 -0
  142. package/dist/types/permission-vc.d.ts.map +1 -0
  143. package/dist/types/receipt.d.ts +133 -0
  144. package/dist/types/receipt.d.ts.map +1 -0
  145. package/dist/types/target-binding.d.ts +163 -0
  146. package/dist/types/target-binding.d.ts.map +1 -0
  147. package/dist/types/tier.d.ts +13 -0
  148. package/dist/types/tier.d.ts.map +1 -0
  149. package/dist/types/vc.d.ts +213 -0
  150. package/dist/types/vc.d.ts.map +1 -0
  151. package/dist/types/vp.d.ts +25 -0
  152. package/dist/types/vp.d.ts.map +1 -0
  153. package/dist/utils/action-classifier.d.ts +13 -0
  154. package/dist/utils/action-classifier.d.ts.map +1 -0
  155. package/dist/utils/crypto.d.ts +22 -0
  156. package/dist/utils/crypto.d.ts.map +1 -0
  157. package/dist/utils/freemail-domains.d.ts +13 -0
  158. package/dist/utils/freemail-domains.d.ts.map +1 -0
  159. package/dist/utils/sdjwt-client.d.ts +415 -0
  160. package/dist/utils/sdjwt-client.d.ts.map +1 -0
  161. package/dist/utils/sdjwt-disclosure.d.ts +13 -0
  162. package/dist/utils/sdjwt-disclosure.d.ts.map +1 -0
  163. package/dist/utils/tier-utils.d.ts +15 -0
  164. package/dist/utils/tier-utils.d.ts.map +1 -0
  165. package/dist/vc/api-vc-manager.d.ts +43 -0
  166. package/dist/vc/api-vc-manager.d.ts.map +1 -0
  167. package/dist/vc/vc-manager.d.ts +55 -0
  168. package/dist/vc/vc-manager.d.ts.map +1 -0
  169. package/dist/vp/kb-jwt-builder.d.ts +89 -0
  170. package/dist/vp/kb-jwt-builder.d.ts.map +1 -0
  171. package/dist/vp/vp-manager.d.ts +75 -0
  172. package/dist/vp/vp-manager.d.ts.map +1 -0
  173. package/package.json +66 -0
package/README.md ADDED
@@ -0,0 +1,265 @@
1
+ # @vess-id/ai-identity
2
+
3
+ TypeScript SDK for AI Identity Layer — secure delegation and permission management for AI agents using W3C Verifiable Credentials (VCs), Verifiable Presentations (VPs), and SD-JWT.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @vess-id/ai-identity
9
+ # or
10
+ pnpm add @vess-id/ai-identity
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { AIdentityClient } from '@vess-id/ai-identity'
17
+
18
+ // Initialize client
19
+ const client = new AIdentityClient({
20
+ proxyApi: {
21
+ baseUrl: 'http://localhost:3000',
22
+ },
23
+ })
24
+
25
+ // Create agent with its own did:jwk identity
26
+ const agent = await client.setup()
27
+
28
+ // Issue a tool permission VC
29
+ const vc = await client.issueToolPermission('slack', 'message.post', {
30
+ subjectDid: agent.did,
31
+ resourceScope: { channel: 'C123456' },
32
+ expiresIn: '1h',
33
+ })
34
+
35
+ // Invoke tool with VC authorization
36
+ const result = await client.invokeTool(
37
+ 'slack',
38
+ 'message.post',
39
+ { channel: 'C123456', text: 'Hello from AI Agent!' },
40
+ [vc]
41
+ )
42
+ ```
43
+
44
+ ## Architecture
45
+
46
+ ```
47
+ User (Issuer) Agent (Subject) Service
48
+ │ │ │
49
+ ├─── issue VC ──────────────►│ │
50
+ │ (permission grant) │ │
51
+ │ ├─── present VP ───────────►│
52
+ │ │ (prove permission) │
53
+ │ │◄──── response ────────────┤
54
+ ```
55
+
56
+ - **Users** issue Verifiable Credentials to delegate permissions to agents
57
+ - **Agents** create Verifiable Presentations to prove their permissions
58
+ - **Services** verify VPs before executing operations
59
+
60
+ ## Core Modules
61
+
62
+ ### AIdentityClient
63
+
64
+ The main orchestrator that provides access to all managers:
65
+
66
+ ```typescript
67
+ const client = new AIdentityClient(config?, password?)
68
+
69
+ client.agent // AgentManager — agent creation, export/import, lifecycle
70
+ client.user // UserIdentityManager — user DID management
71
+ client.vc // VCManager — VC issuance (SD-JWT)
72
+ client.vp // VPManager — VP creation and verification
73
+ client.tool // ToolManager — tool invocation with VP authorization
74
+ client.grant // GrantManager — grant suggestion and confirmation
75
+ ```
76
+
77
+ ### Agent Management
78
+
79
+ ```typescript
80
+ // Create agent with did:jwk identity
81
+ const agent = await client.setup()
82
+
83
+ // List agents
84
+ const agents = await client.agent.list()
85
+
86
+ // Export/import agent (including private key)
87
+ const backup = await client.agent.export(agent.did)
88
+ await client.agent.import(backup.agent, backup.privateKey)
89
+ ```
90
+
91
+ Agent types: `autonomous`, `sub_agent`, `tool_agent`, `assistant`, `proxy`
92
+
93
+ ### Verifiable Credentials
94
+
95
+ Issue SD-JWT VCs with selective disclosure:
96
+
97
+ ```typescript
98
+ // Tool permission
99
+ const vc = await client.issueToolPermission('github', 'issue.create', {
100
+ subjectDid: agent.did,
101
+ expiresIn: '24h',
102
+ })
103
+
104
+ // Data access
105
+ const vc = await client.issueDataAccess('slack:channel', ['read'], {
106
+ subjectDid: agent.did,
107
+ })
108
+ ```
109
+
110
+ VC types: `ToolAccessCredential`, `ProjectAccessCredential`, `DeveloperCredential`, `TemporaryCredential`, `AdminCredential`, `ReceiptCredential`
111
+
112
+ ### Verifiable Presentations
113
+
114
+ ```typescript
115
+ // Create VP (with holder binding via KB-JWT)
116
+ const vp = await client.vp.create([vc1, vc2], {
117
+ holderDid: agent.did,
118
+ challenge: 'nonce-123',
119
+ domain: 'api.example.com',
120
+ })
121
+
122
+ // Verify VP
123
+ const result = await client.vp.verify(vp, {
124
+ expectedChallenge: 'nonce-123',
125
+ expectedDomain: 'api.example.com',
126
+ })
127
+ ```
128
+
129
+ ### Tool Invocation
130
+
131
+ ```typescript
132
+ const result = await client.invokeTool<SlackResponse>(
133
+ 'slack',
134
+ 'message.post',
135
+ { channel: 'C123456', text: 'Hello!' },
136
+ [vc]
137
+ )
138
+ ```
139
+
140
+ ## Action Registry
141
+
142
+ All supported actions are defined in `ACTION_REGISTRY` using `provider.resource.operation` format:
143
+
144
+ | Provider | Actions |
145
+ |----------|---------|
146
+ | **Slack** | `message.post`, `message.read`, `message.update`, `message.delete`, `channel.read`, `user.read`, `batch.read` |
147
+ | **GitHub** | `issue.create`, `issue.list`, `issue.read`, `issue.update` |
148
+ | **Gmail** | `message.search`, `message.read`, `message.send`, `label.read`, `batch.read` |
149
+ | **Calendar** | Calendar operations |
150
+ | **JIRA** | Issue management |
151
+ | **OS** | Local operations |
152
+
153
+ Each action defines: risk level, required relations, required scopes, input schema, constraints, and effects.
154
+
155
+ ```typescript
156
+ import { ACTION_REGISTRY, indexActions } from '@vess-id/ai-identity'
157
+
158
+ const actions = indexActions(ACTION_REGISTRY)
159
+ const slackPost = actions.get('slack.message.post')
160
+ // { risk: 'high', required_relations: ['editor', 'admin', ...], ... }
161
+ ```
162
+
163
+ ## Permission Constraints
164
+
165
+ Fine-grained access control on VCs:
166
+
167
+ ```typescript
168
+ interface PermissionConstraints {
169
+ time?: {
170
+ not_before?: number // Unix timestamp
171
+ not_after?: number
172
+ recurring_start?: string // "09:00"
173
+ recurring_end?: string // "17:00"
174
+ days_of_week?: number[] // [1,2,3,4,5] (Mon-Fri)
175
+ timezone?: string
176
+ }
177
+ max_invocations?: number
178
+ rate_limit_per_min?: number
179
+ }
180
+ ```
181
+
182
+ The `ConstraintEvaluator` checks: expiration, invocation limits, time windows, IP allowlists, and risk thresholds.
183
+
184
+ ## Registry Utilities
185
+
186
+ ```typescript
187
+ import {
188
+ // Action normalization (MCP interop)
189
+ normalizeMcpActionName,
190
+ getAllValidMcpActionNames,
191
+
192
+ // Action aliases
193
+ canonicalizeAction,
194
+ isActionEquivalent,
195
+
196
+ // Providers
197
+ resolveProvider,
198
+ CANONICAL_PROVIDERS, // 'slack' | 'github' | 'gmail' | 'calendar' | 'jira' | 'os'
199
+
200
+ // Access orchestration (ABAC/ReBAC)
201
+ resolveActionsFromSelection,
202
+ planDelegationForVC,
203
+ checkPermissionWithVP,
204
+ } from '@vess-id/ai-identity'
205
+ ```
206
+
207
+ ## Gateway Client
208
+
209
+ Event-based communication for CLI and daemon:
210
+
211
+ ```typescript
212
+ import { GatewayClient } from '@vess-id/ai-identity'
213
+
214
+ const gateway = new GatewayClient({ baseUrl: 'https://app.vesslabs.ai' })
215
+
216
+ // Long-poll for events
217
+ const { events, cursor } = await gateway.getEvents({
218
+ cursor: lastCursor,
219
+ waitSeconds: 30,
220
+ })
221
+
222
+ // Acknowledge processed event
223
+ await gateway.ackEvent(event.id)
224
+ ```
225
+
226
+ ## Configuration
227
+
228
+ ```typescript
229
+ interface AIdentityConfig {
230
+ didApi?: {
231
+ baseUrl: string
232
+ apiKey?: string
233
+ bearerToken?: string
234
+ }
235
+ issuerApi?: {
236
+ baseUrl: string
237
+ apiKey?: string
238
+ bearerToken?: string
239
+ }
240
+ verifierApi?: {
241
+ baseUrl: string
242
+ apiKey?: string
243
+ bearerToken?: string
244
+ }
245
+ proxyApi?: {
246
+ baseUrl: string
247
+ }
248
+ storage?: {
249
+ keyStorePath?: string // Default: ~/.vess-aidentity/keys
250
+ }
251
+ }
252
+ ```
253
+
254
+ ## Security
255
+
256
+ - Agents use `did:jwk` identifiers with EC P-256 key pairs
257
+ - Private keys are stored locally with optional password encryption
258
+ - VCs use SD-JWT format with selective disclosure
259
+ - VPs include nonce and domain binding to prevent replay attacks
260
+ - All tool invocations require valid VP authorization
261
+ - Constraint evaluation enforces time windows, invocation limits, IP allowlists, and risk thresholds
262
+
263
+ ## License
264
+
265
+ MIT
@@ -0,0 +1,97 @@
1
+ import { KeyManager } from '../did/key-manager';
2
+ export interface AgentDIDManagerOptions {
3
+ /**
4
+ * Directory holding the `<agentId>.did` files that map an agent ID to its DID.
5
+ *
6
+ * 🔴 Omit this and the default stays exactly what it has always been —
7
+ * `~/.vess-aidentity/agent-dids/`. Every mapping written so far lives there,
8
+ * so changing the default would make existing agents unresolvable.
9
+ *
10
+ * Supply it for either of two reasons:
11
+ *
12
+ * - **Tenant isolation.** With the path hard-coded to `os.homedir()`, one
13
+ * process serving several tenants funnels all of them into a single shared
14
+ * directory, where agent IDs can collide across tenants.
15
+ *
16
+ * - **Test isolation.** Tests could not otherwise steer this path away from
17
+ * the developer's real home. Under jest, `process.env.HOME = x` does not
18
+ * help: jest-environment-node replaces `process.env` with a plain object
19
+ * behind a Proxy, so the assignment never reaches `setenv(3)`, while
20
+ * `os.homedir()` goes through libuv to `getenv("HOME")` and reads the real
21
+ * environ. Both reads and writes therefore escape to the real home and the
22
+ * suite stays green while polluting it.
23
+ */
24
+ mappingDir?: string;
25
+ }
26
+ /**
27
+ * Agent DID Manager
28
+ * Manages DID generation and lifecycle for AI Agents specifically
29
+ */
30
+ export declare class AgentDIDManager {
31
+ private keyManager;
32
+ private agentDIDMap;
33
+ private readonly mappingDirOverride?;
34
+ constructor(keyManager?: KeyManager, options?: AgentDIDManagerOptions);
35
+ /**
36
+ * 🔴 The one place the mapping directory is derived.
37
+ *
38
+ * It used to be derived independently in four methods, and two of them
39
+ * (`loadAgentDIDMapping` / `deleteAgentDIDMapping`) looked at `~/.vess/`
40
+ * while the writes went to `~/.vess-aidentity/`. Within a single process the
41
+ * in-memory Map answered first, so nobody noticed; across processes
42
+ * `getAgentDID` failed every time — whenever a long-lived host restarts, or
43
+ * on each Lambda invocation. The four copies are now one, so the paths
44
+ * cannot drift apart again.
45
+ *
46
+ * (An earlier version of this note named agentd as the example. It is not
47
+ * one: agentd resolves Agent DIDs through its own store — OS keychain plus
48
+ * SQLite, keyed by project × client — and takes only stateless primitives
49
+ * from this SDK. Nothing in this repo constructs an AgentDIDManager; the
50
+ * callers are SDK consumers.)
51
+ *
52
+ * The default resolves to `.vess-aidentity` because that is where the real
53
+ * files ended up; treating `.vess` as canonical would orphan every existing
54
+ * mapping.
55
+ */
56
+ private mappingDir;
57
+ /**
58
+ * Generate a new DID for an AI Agent
59
+ */
60
+ generateAgentDID(agentId: string): Promise<string>;
61
+ /**
62
+ * Get DID for a specific agent
63
+ */
64
+ getAgentDID(agentId: string): Promise<string>;
65
+ /**
66
+ * Check if agent has a DID
67
+ */
68
+ hasAgentDID(agentId: string): Promise<boolean>;
69
+ /**
70
+ * Get agent's key pair
71
+ */
72
+ getAgentKeyPair(agentId: string): Promise<any>;
73
+ /**
74
+ * Delete agent DID and associated keys
75
+ */
76
+ deleteAgentDID(agentId: string): Promise<void>;
77
+ /**
78
+ * List all agent DIDs
79
+ */
80
+ listAgentDIDs(): Promise<Array<{
81
+ agentId: string;
82
+ did: string;
83
+ }>>;
84
+ /**
85
+ * Save agent ID -> DID mapping to persistent storage
86
+ */
87
+ private saveAgentDIDMapping;
88
+ /**
89
+ * Load agent ID -> DID mapping from persistent storage
90
+ */
91
+ private loadAgentDIDMapping;
92
+ /**
93
+ * Delete agent ID -> DID mapping from persistent storage
94
+ */
95
+ private deleteAgentDIDMapping;
96
+ }
97
+ //# sourceMappingURL=agent-did-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-did-manager.d.ts","sourceRoot":"","sources":["../../src/agent/agent-did-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAI/C,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAQ;gBAEhC,UAAU,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAKrE;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,UAAU;IASxB;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBxD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBnD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAcpD;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpD;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IA2BvE;;OAEG;YACW,mBAAmB;IAYjC;;OAEG;YACW,mBAAmB;IAcjC;;OAEG;YACW,qBAAqB;CAapC"}
@@ -0,0 +1,51 @@
1
+ import { IStateStore } from '../state/state-store.interface';
2
+ import { GatewayClient, ApiKeyValidationResult } from '../gateway/gateway-client';
3
+ /**
4
+ * Authentication state persisted in the StateStore
5
+ */
6
+ export interface AuthState {
7
+ apiKey: string;
8
+ apiUrl: string;
9
+ userId?: string;
10
+ projectId?: string;
11
+ scopes?: string[];
12
+ authenticatedAt: string;
13
+ }
14
+ /**
15
+ * Authentication provider that validates API keys and persists auth state.
16
+ * Used by CLI and MCP to authenticate against the Gateway API.
17
+ */
18
+ export declare class AuthProvider {
19
+ private stateStore;
20
+ private gatewayClient;
21
+ constructor(stateStore: IStateStore, gatewayClient: GatewayClient);
22
+ /**
23
+ * Authenticate with an API key. Validates against the Gateway and
24
+ * persists the result in the StateStore.
25
+ *
26
+ * @returns The validation result
27
+ */
28
+ login(apiKey: string, apiUrl: string, projectId?: string): Promise<ApiKeyValidationResult>;
29
+ /**
30
+ * Get the current auth state from the StateStore.
31
+ * Returns undefined if not authenticated.
32
+ */
33
+ getAuthState(): Promise<AuthState | undefined>;
34
+ /**
35
+ * Check if we have stored auth credentials
36
+ */
37
+ isAuthenticated(): Promise<boolean>;
38
+ /**
39
+ * Clear auth state (logout)
40
+ */
41
+ logout(): Promise<void>;
42
+ /**
43
+ * Get the stored API key, or undefined if not authenticated
44
+ */
45
+ getApiKey(): Promise<string | undefined>;
46
+ /**
47
+ * Get the stored API URL, or undefined if not authenticated
48
+ */
49
+ getApiUrl(): Promise<string | undefined>;
50
+ }
51
+ //# sourceMappingURL=auth-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../../src/auth/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAEjF;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,aAAa,CAAe;gBAExB,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAKjE;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAkBhG;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAIpD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKzC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK9C;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAI/C"}
@@ -0,0 +1,2 @@
1
+ export { AuthProvider, AuthState } from './auth-provider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,63 @@
1
+ import { type AIdentityConfig } from './config';
2
+ import { AgentManager } from './did/agent';
3
+ import { UserIdentityManager } from './identity/user-identity-manager';
4
+ import { VCManager } from './vc/vc-manager';
5
+ import { VPManager } from './vp/vp-manager';
6
+ import { ToolManager } from './tool/tool-manager';
7
+ import { GrantManager } from './grant/grant-manager';
8
+ import { Agent, ConnectorResponse } from './types';
9
+ export declare class AIdentityClient {
10
+ readonly agent: AgentManager;
11
+ readonly user: UserIdentityManager;
12
+ readonly vc: VCManager;
13
+ readonly vp: VPManager;
14
+ readonly tool: ToolManager;
15
+ readonly grant: GrantManager;
16
+ private keyManager;
17
+ private currentAgent?;
18
+ constructor(config?: AIdentityConfig, password?: string);
19
+ /**
20
+ * Quick setup: Create or load an agent
21
+ */
22
+ setup(did?: string): Promise<Agent>;
23
+ /**
24
+ * Get current agent
25
+ */
26
+ getCurrentAgent(): Agent | undefined;
27
+ /**
28
+ * Get current user DID
29
+ */
30
+ getCurrentUserDID(): Promise<string>;
31
+ /**
32
+ * Create or reset user identity
33
+ */
34
+ resetUserIdentity(): Promise<string>;
35
+ /**
36
+ * Issue a VC for tool permission
37
+ * Enhanced to support User → Agent delegation pattern
38
+ */
39
+ issueToolPermission(tool: string, action: string, options: {
40
+ subjectDid?: string;
41
+ agentId?: string;
42
+ issuerDid?: string;
43
+ resourceScope?: Record<string, any>;
44
+ expiresIn?: string;
45
+ }): Promise<string>;
46
+ /**
47
+ * Issue a VC for data access
48
+ * Enhanced to support User → Agent delegation pattern
49
+ */
50
+ issueDataAccess(resource: string, actions: ('read' | 'write' | 'delete')[], options: {
51
+ subjectDid?: string;
52
+ agentId?: string;
53
+ issuerDid?: string;
54
+ expiresIn?: string;
55
+ }): Promise<string>;
56
+ /**
57
+ * Invoke a tool with automatic VP creation
58
+ */
59
+ invokeTool<T = any>(tool: string, action: string, params: Record<string, any>, vcs: string[]): Promise<ConnectorResponse<T>>;
60
+ }
61
+ export declare function getClient(config?: AIdentityConfig, password?: string): AIdentityClient;
62
+ export { configure, type AIdentityConfig } from './config';
63
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAa,MAAM,UAAU,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAElD,qBAAa,eAAe;IAC1B,SAAgB,KAAK,EAAE,YAAY,CAAA;IACnC,SAAgB,IAAI,EAAE,mBAAmB,CAAA;IACzC,SAAgB,EAAE,EAAE,SAAS,CAAA;IAC7B,SAAgB,EAAE,EAAE,SAAS,CAAA;IAC7B,SAAgB,IAAI,EAAE,WAAW,CAAA;IACjC,SAAgB,KAAK,EAAE,YAAY,CAAA;IAEnC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,YAAY,CAAC,CAAO;gBAEhB,MAAM,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM;IAuBvD;;OAEG;IACG,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAWzC;;OAEG;IACH,eAAe,IAAI,KAAK,GAAG,SAAS;IAIpC;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C;;;OAGG;IACG,mBAAmB,CACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACnC,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,GACA,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;OAGG;IACG,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,EACxC,OAAO,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,GACA,OAAO,CAAC,MAAM,CAAC;IAgBlB;;OAEG;IACG,UAAU,CAAC,CAAC,GAAG,GAAG,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,GAAG,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAWjC;AAKD,wBAAgB,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CAKtF;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,84 @@
1
+ import type { KeyStorageProvider } from '../storage/key-storage.interface';
2
+ export interface AIdentityConfig {
3
+ didApi?: {
4
+ baseUrl: string;
5
+ apiKey?: string;
6
+ bearerToken?: string;
7
+ };
8
+ issuerApi?: {
9
+ baseUrl: string;
10
+ apiKey?: string;
11
+ bearerToken?: string;
12
+ };
13
+ verifierApi?: {
14
+ baseUrl: string;
15
+ apiKey?: string;
16
+ bearerToken?: string;
17
+ };
18
+ proxyApi?: {
19
+ baseUrl: string;
20
+ };
21
+ storage?: {
22
+ keyStorePath?: string;
23
+ };
24
+ /**
25
+ * Where agentId → DID mappings are kept.
26
+ *
27
+ * 🔴 Leave it unset and the default is unchanged: `~/.vess-aidentity/agent-dids`.
28
+ * Every mapping written so far lives there, so moving the default would make
29
+ * existing agents unresolvable.
30
+ *
31
+ * Set it when a single process serves several tenants — otherwise they all
32
+ * share one directory and agent IDs can collide across them — or when a test
33
+ * must not touch the developer's real home.
34
+ *
35
+ * Reaches `AgentDIDManager` through `AgentManager`; without this field a
36
+ * caller could implement nothing and had no way to move the path, the same
37
+ * gap `keyStorage` closed for private keys.
38
+ */
39
+ agentMappingDir?: string;
40
+ /**
41
+ * Where the user DID (`user-did.txt`) is kept.
42
+ *
43
+ * 🔴 Leave it unset and the default is unchanged: `~/.vess-aidentity`. Note
44
+ * this is the config root itself, not a subdirectory — the user DID is one
45
+ * fixed filename sitting alongside `keys/` and `agent-dids/`. Moving the
46
+ * default would orphan the existing identity, and every VC issued so far
47
+ * names that DID as its issuer.
48
+ *
49
+ * Set it when a single process serves several tenants — the filename is
50
+ * fixed, so without it the last `createUserDID` overwrites every other
51
+ * tenant's issuer identity — or when a test must not touch the developer's
52
+ * real home.
53
+ *
54
+ * Reaches `UserIdentityManager` through `AIdentityClient`; separate from
55
+ * `agentMappingDir` because the two point at different directories and a
56
+ * caller may well want to move only one.
57
+ */
58
+ userMappingDir?: string;
59
+ /**
60
+ * Where private keys are kept.
61
+ *
62
+ * 🔴 Supply this when the filesystem is not durable. On AWS Lambda and
63
+ * similar, the default provider writes to a disk that is wiped between
64
+ * invocations, so keys fail to persist SILENTLY — nothing throws at
65
+ * construction, and the failure surfaces later as a key that cannot be
66
+ * found.
67
+ *
68
+ * `KeyManager` has always accepted a provider; what was missing was a way
69
+ * to reach it from here, so a client could implement the interface and had
70
+ * nowhere to put the result. Distinct from `storage.keyStorePath`, which
71
+ * only moves the filesystem provider's directory and cannot replace it.
72
+ *
73
+ * Implement `KeyStorageProvider` against S3, DynamoDB, Secrets Manager or
74
+ * anything else; `MemoryKeyStorage` is exported for the ephemeral case.
75
+ */
76
+ keyStorage?: KeyStorageProvider;
77
+ }
78
+ export declare function configure(config: AIdentityConfig): void;
79
+ export declare function getConfig(): AIdentityConfig;
80
+ export declare function getDidApiUrl(path: string): string;
81
+ export declare function getIssuerApiUrl(path: string): string;
82
+ export declare function getVerifierApiUrl(path: string): string;
83
+ export declare function getApiHeaders(apiType: 'did' | 'issuer' | 'verifier'): any;
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAE1E,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,WAAW,CAAC,EAAE;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IAED;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAChC;AAID,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAEvD;AAED,wBAAgB,SAAS,IAAI,eAAe,CAE3C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,UAAU,GAAG,GAAG,CA+BzE"}