@nodatachat/sdk 1.0.0 → 2.0.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NoDataConfig, C as ChannelCreateRequest, a as ChannelCreateResponse, b as ChannelSendRequest, c as ChannelSendResponse, d as ChannelReceiveRequest, e as ChannelReceiveResponse, W as WebhookChannelCreateRequest, f as WebhookChannelCreateResponse, g as WebhookEventsResponse, D as DeliverRequest, h as DeliverResponse, E as EvidenceQuery, i as EvidenceResponse, V as VaultCreateRequest, j as VaultCreateResponse, k as VaultReadResponse, l as EncryptRequest, m as EncryptResponse, n as DecryptRequest, o as DecryptResponse, B as BatchResult } from './types-DQh0UmSr.js';
2
- export { p as EvidenceEntry, q as NoDataError, P as PluginConfig, r as WebhookEvent } from './types-DQh0UmSr.js';
1
+ import { N as NoDataConfig, A as AgentReadRequest, a as AgentReadResponse, R as RegisterTableRequest, b as RegisterTableResponse, G as GrantRequest, c as GrantResponse, d as RevokeRequest, e as RevokeResponse, V as VaultCreateRequest, f as VaultCreateResponse, g as VaultReadResponse, E as EvidenceQuery, h as EvidenceResponse, D as DeliverRequest, i as DeliverResponse, W as WebhookChannelCreateRequest, j as WebhookChannelCreateResponse, k as WebhookEventsResponse, C as ChannelCreateRequest, l as ChannelCreateResponse, m as ChannelSendRequest, n as ChannelSendResponse, o as ChannelReceiveRequest, p as ChannelReceiveResponse, q as EncryptRequest, r as EncryptResponse, s as DecryptRequest, t as DecryptResponse, B as BatchResult, u as ComputeRequest, v as ComputeDecision, w as VerifyResult } from './types-BQZ_zF32.js';
2
+ export { x as Clearance, y as ComputeSection, z as EvidenceEntry, F as NoDataError, P as PluginConfig, H as RegisteredTable, I as WebhookEvent } from './types-BQZ_zF32.js';
3
3
 
4
4
  declare class HttpClient {
5
5
  private apiKey;
@@ -12,72 +12,171 @@ declare class HttpClient {
12
12
  private onError?;
13
13
  constructor(config: NoDataConfig);
14
14
  request<T>(method: string, path: string, body?: unknown, query?: Record<string, string>): Promise<T>;
15
+ /** Base URL the client targets · used by surfaces that auth with a
16
+ * different bearer than the API key (e.g. an agent grant token). */
17
+ get baseURL(): string;
15
18
  get<T>(path: string, query?: Record<string, string>): Promise<T>;
16
19
  post<T>(path: string, body?: unknown): Promise<T>;
17
20
  del<T>(path: string, body?: unknown): Promise<T>;
18
21
  }
19
22
 
20
- declare class ChannelModule {
23
+ declare class GovernanceModule {
24
+ private http;
25
+ constructor(http: HttpClient);
26
+ /** Register one of your own tables as AI-agent-readable. "Connect your
27
+ * data" — a config call, not a code change. Idempotent per table. */
28
+ registerTable(req: RegisterTableRequest): Promise<RegisterTableResponse>;
29
+ /** List your registered agent tables. */
30
+ listTables(): Promise<RegisterTableResponse>;
31
+ /** Issue an AI agent a claim-scoped grant over your data. Returns a
32
+ * grant token (shown once) the agent presents to read. */
33
+ grant(req: GrantRequest): Promise<GrantResponse>;
34
+ /** Revoke a grant by agent handle (revokes all active credentials for
35
+ * that agent) or by a specific jti. */
36
+ revoke(req: RevokeRequest): Promise<RevokeResponse>;
37
+ }
38
+ /**
39
+ * A reader bound to a single agent grant token. Authenticates with the
40
+ * grant token (NOT your API key), so this is exactly what an LLM/agent
41
+ * runtime would hold. Denied columns never decrypt server-side.
42
+ */
43
+ declare class AgentReader {
44
+ private baseURL;
45
+ private grantToken;
46
+ constructor(baseURL: string, grantToken: string);
47
+ read(req: AgentReadRequest): Promise<AgentReadResponse>;
48
+ }
49
+
50
+ declare class VaultModule {
21
51
  private http;
22
52
  constructor(http: HttpClient);
23
53
  /**
24
- * Create a secure channel for data transfer.
25
- *
26
- * Returns a channel_token that the sender uses, and optionally
27
- * a verification_code for the receiver.
54
+ * Store an encrypted blob in the vault.
55
+ * YOU encrypt client-side. Server stores blindly.
28
56
  *
29
57
  * @example
30
58
  * ```ts
31
- * // System A creates a channel
32
- * const ch = await nd.channel.create({ ttl: "1h", requireVerification: true });
33
- * // Send ch.channel_token to System B (the sender)
34
- * // Send ch.verification_code to the receiver (out-of-band)
59
+ * // Encrypt client-side, then store
60
+ * const blob = myEncrypt(sensitiveData, myKey);
61
+ * const vault = await nd.vault.create({
62
+ * label: "customer-contracts",
63
+ * encrypted_blob: blob.ciphertext,
64
+ * iv: blob.iv,
65
+ * metadata: { customer_id: "cust_123" },
66
+ * });
35
67
  * ```
36
68
  */
37
- create(req?: ChannelCreateRequest): Promise<ChannelCreateResponse>;
69
+ create(req: VaultCreateRequest): Promise<VaultCreateResponse>;
38
70
  /**
39
- * Send data through a secure channel.
40
- * Data is encrypted in transit — the server never sees plaintext.
71
+ * Retrieve an encrypted blob from the vault.
72
+ * YOU decrypt client-side.
73
+ */
74
+ read(vaultId: string): Promise<VaultReadResponse>;
75
+ /**
76
+ * Delete a vault entry (irreversible).
77
+ */
78
+ delete(vaultId: string): Promise<{
79
+ success: boolean;
80
+ }>;
81
+ /**
82
+ * Check vault service status.
83
+ */
84
+ status(): Promise<{
85
+ success: boolean;
86
+ vault_count: number;
87
+ storage_used_bytes: number;
88
+ }>;
89
+ }
90
+
91
+ declare class EvidenceModule {
92
+ private http;
93
+ constructor(http: HttpClient);
94
+ /**
95
+ * Query the audit trail.
96
+ * Returns metadata only — never content.
41
97
  *
42
98
  * @example
43
99
  * ```ts
44
- * // System B sends credit card data to System A
45
- * await nd.channel.send({
46
- * token: ch.channel_token,
47
- * data: { card: "4111111111111111", cvv: "123" },
48
- * burnAfterRead: true,
100
+ * const trail = await nd.evidence.query({
101
+ * field: "credit_card",
102
+ * action: "decrypt",
103
+ * from: "2026-03-01",
104
+ * to: "2026-03-27",
49
105
  * });
106
+ * // Shows WHO decrypted WHAT field WHEN — for SOC compliance
50
107
  * ```
51
108
  */
52
- send(req: ChannelSendRequest): Promise<ChannelSendResponse>;
109
+ query(q?: EvidenceQuery): Promise<EvidenceResponse>;
53
110
  /**
54
- * Receive data from a secure channel.
111
+ * Generate a proof certificate for a specific operation.
112
+ */
113
+ certificate(auditId: string): Promise<{
114
+ success: boolean;
115
+ certificate: {
116
+ audit_id: string;
117
+ proof_hash: string;
118
+ merkle_root: string;
119
+ timestamp: string;
120
+ algorithm: string;
121
+ };
122
+ }>;
123
+ /**
124
+ * Verify a receipt/proof hash.
125
+ */
126
+ verify(proofHash: string): Promise<{
127
+ success: boolean;
128
+ valid: boolean;
129
+ entry?: {
130
+ action: string;
131
+ field_name: string;
132
+ created_at: string;
133
+ };
134
+ }>;
135
+ }
136
+
137
+ declare class DeliverModule {
138
+ private http;
139
+ constructor(http: HttpClient);
140
+ /**
141
+ * Create a secure, self-destructing delivery.
142
+ *
143
+ * Use for: credit card numbers, passwords, API keys, PII.
144
+ * The recipient opens the link, sees the content ONCE, and it burns.
55
145
  *
56
146
  * @example
57
147
  * ```ts
58
- * // System A retrieves the data
59
- * const result = await nd.channel.receive({
60
- * token: ch.channel_token,
61
- * verificationCode: "123456",
148
+ * // Send a credit card number securely
149
+ * const d = await nd.deliver.send({
150
+ * content: "4111-1111-1111-1111",
151
+ * ttl: "1h",
152
+ * burn: true,
153
+ * maxViews: 1,
62
154
  * });
63
- * const card = JSON.parse(result.data);
155
+ * // Send d.delivery_url to the recipient
156
+ * // After they open it — gone forever
64
157
  * ```
65
158
  */
66
- receive(req: ChannelReceiveRequest): Promise<ChannelReceiveResponse>;
159
+ send(req: DeliverRequest): Promise<DeliverResponse>;
67
160
  /**
68
- * Verify a channel recipient with a code (out-of-band verification).
161
+ * Create an anonymous burn drop (no auth required on read side).
69
162
  */
70
- verify(token: string, code: string): Promise<{
163
+ burn(content: string, options?: {
164
+ ttlHours?: number;
165
+ burnAfterRead?: boolean;
166
+ availableAt?: string;
167
+ }): Promise<{
71
168
  success: boolean;
169
+ drop_id: string;
170
+ read_url: string;
171
+ expires_at: string;
72
172
  }>;
73
173
  /**
74
- * Get delivery proof (Merkle-based).
174
+ * Read a burn drop (self-destructs on read if configured).
75
175
  */
76
- proof(channelToken: string): Promise<{
176
+ read(dropId: string): Promise<{
77
177
  success: boolean;
78
- proof_hash: string;
79
- merkle_root: string;
80
- delivery_chain: string[];
178
+ content: string;
179
+ burned: boolean;
81
180
  }>;
82
181
  }
83
182
 
@@ -129,156 +228,745 @@ declare class WebhookModule {
129
228
  }>;
130
229
  }
131
230
 
132
- declare class DeliverModule {
231
+ declare class ChannelModule {
133
232
  private http;
134
233
  constructor(http: HttpClient);
135
234
  /**
136
- * Create a secure, self-destructing delivery.
235
+ * Create a secure channel for data transfer.
137
236
  *
138
- * Use for: credit card numbers, passwords, API keys, PII.
139
- * The recipient opens the link, sees the content ONCE, and it burns.
237
+ * Returns a channel_token that the sender uses, and optionally
238
+ * a verification_code for the receiver.
140
239
  *
141
240
  * @example
142
241
  * ```ts
143
- * // Send a credit card number securely
144
- * const d = await nd.deliver.send({
145
- * content: "4111-1111-1111-1111",
146
- * ttl: "1h",
147
- * burn: true,
148
- * maxViews: 1,
242
+ * // System A creates a channel
243
+ * const ch = await nd.channel.create({ ttl: "1h", requireVerification: true });
244
+ * // Send ch.channel_token to System B (the sender)
245
+ * // Send ch.verification_code to the receiver (out-of-band)
246
+ * ```
247
+ */
248
+ create(req?: ChannelCreateRequest): Promise<ChannelCreateResponse>;
249
+ /**
250
+ * Send data through a secure channel.
251
+ * Data is encrypted in transit — the server never sees plaintext.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * // System B sends credit card data to System A
256
+ * await nd.channel.send({
257
+ * token: ch.channel_token,
258
+ * data: { card: "4111111111111111", cvv: "123" },
259
+ * burnAfterRead: true,
149
260
  * });
150
- * // Send d.delivery_url to the recipient
151
- * // After they open it — gone forever
152
261
  * ```
153
262
  */
154
- send(req: DeliverRequest): Promise<DeliverResponse>;
263
+ send(req: ChannelSendRequest): Promise<ChannelSendResponse>;
155
264
  /**
156
- * Create an anonymous burn drop (no auth required on read side).
265
+ * Receive data from a secure channel.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * // System A retrieves the data
270
+ * const result = await nd.channel.receive({
271
+ * token: ch.channel_token,
272
+ * verificationCode: "123456",
273
+ * });
274
+ * const card = JSON.parse(result.data);
275
+ * ```
157
276
  */
158
- burn(content: string, options?: {
159
- ttlHours?: number;
160
- burnAfterRead?: boolean;
161
- availableAt?: string;
162
- }): Promise<{
277
+ receive(req: ChannelReceiveRequest): Promise<ChannelReceiveResponse>;
278
+ /**
279
+ * Verify a channel recipient with a code (out-of-band verification).
280
+ */
281
+ verify(token: string, code: string): Promise<{
163
282
  success: boolean;
164
- drop_id: string;
165
- read_url: string;
166
- expires_at: string;
167
283
  }>;
168
284
  /**
169
- * Read a burn drop (self-destructs on read if configured).
285
+ * Get delivery proof (Merkle-based).
170
286
  */
171
- read(dropId: string): Promise<{
287
+ proof(channelToken: string): Promise<{
172
288
  success: boolean;
173
- content: string;
174
- burned: boolean;
289
+ proof_hash: string;
290
+ merkle_root: string;
291
+ delivery_chain: string[];
175
292
  }>;
176
293
  }
177
294
 
178
- declare class EvidenceModule {
295
+ type CapsuleKeyMode = 'server' | 'zk';
296
+ type CapsuleStatus = 'active' | 'frozen' | 'revoked';
297
+ type PortableMode = 'controlled' | 'standalone' | 'both';
298
+ interface CapsuleSummary {
299
+ capsule_id: string;
300
+ slug: string;
301
+ status: CapsuleStatus;
302
+ key_mode: CapsuleKeyMode;
303
+ display_name: string | null;
304
+ document_count: number;
305
+ member_count: number;
306
+ portable_mode: PortableMode;
307
+ created_at: string;
308
+ }
309
+ interface CreateCapsuleRequest {
310
+ /** Tenant-scoped opaque handle, /^[a-z0-9-]{3,64}$/, e.g. "case-4471". */
311
+ handle: string;
312
+ /** Label for your UI (not PII-safe to rely on; real contact is hashed). */
313
+ display_name?: string;
314
+ /** 'server' (default, managed keys) or 'zk' (you hold the capsule private key). */
315
+ key_mode?: CapsuleKeyMode;
316
+ /** Required when key_mode='zk': base64url X25519 public key. */
317
+ capsule_pubkey?: string;
318
+ portable_mode?: PortableMode;
319
+ /** Hashed server-side into email_hash; the plaintext never reaches storage. */
320
+ email?: string;
321
+ phone?: string;
322
+ }
323
+ interface ListCapsulesResponse {
324
+ ok: boolean;
325
+ capsules: CapsuleSummary[];
326
+ }
327
+ interface DocumentSection {
328
+ id?: string;
329
+ label: string;
330
+ /** public | internal | restricted | confidential | attorney_client | field:<col> | structure */
331
+ classification: string;
332
+ /** The section body. Encrypted at seal time; the server never stores plaintext. */
333
+ text: string;
334
+ }
335
+ interface DocumentRecipient {
336
+ email: string;
337
+ classifications: string[];
338
+ /** Optional owner-chosen passphrase that opens ONLY this recipient's classifications. */
339
+ code?: string;
340
+ }
341
+ interface AddDocumentRequest {
342
+ title?: string;
343
+ /** Convenience: a single-section document. Ignored when `sections` is provided. */
344
+ content?: string;
345
+ classification?: string;
346
+ /** Full multi-section document (a key per recipient via `recipients`). */
347
+ sections?: DocumentSection[];
348
+ recipients?: DocumentRecipient[];
349
+ /** Use the tenant zero-knowledge path (existing behavior; per-capsule zk is Phase 1). */
350
+ zero_knowledge?: boolean;
351
+ }
352
+ interface AddDocumentResponse {
353
+ ok: boolean;
354
+ capsule_id: string;
355
+ lockbox_id: string;
356
+ sections_count: number;
357
+ classifications: string[];
358
+ recipients_saved: number;
359
+ recipient_codes: Array<{
360
+ email: string;
361
+ classifications: string[];
362
+ code: string;
363
+ }>;
364
+ recipient_url: string;
365
+ bearer_token: string;
366
+ activation_code: string;
367
+ }
368
+ interface DocumentSummary {
369
+ lockbox_id: string;
370
+ title: string | null;
371
+ status: string;
372
+ issued_at: string;
373
+ recipient_count: number;
374
+ }
375
+ interface ListDocumentsResponse {
376
+ ok: boolean;
377
+ capsule_id: string;
378
+ documents: DocumentSummary[];
379
+ }
380
+ /** Document sub-resource on a capsule handle. */
381
+ declare class CapsuleDocuments {
179
382
  private http;
180
- constructor(http: HttpClient);
383
+ private ref;
384
+ constructor(http: HttpClient, ref: string);
181
385
  /**
182
- * Query the audit trail.
183
- * Returns metadata only — never content.
184
- *
386
+ * Seal a document into the capsule.
185
387
  * @example
186
388
  * ```ts
187
- * const trail = await nd.evidence.query({
188
- * field: "credit_card",
189
- * action: "decrypt",
190
- * from: "2026-03-01",
191
- * to: "2026-03-27",
192
- * });
193
- * // Shows WHO decrypted WHAT field WHEN — for SOC compliance
389
+ * await cap.documents.add({ title: 'Policy', content: '…', classification: 'confidential' });
390
+ * // or multi-section, a key per recipient:
391
+ * await cap.documents.add({ title: 'Case', sections: [...], recipients: [{ email, classifications, code }] });
194
392
  * ```
195
393
  */
196
- query(q?: EvidenceQuery): Promise<EvidenceResponse>;
394
+ add(req: AddDocumentRequest): Promise<AddDocumentResponse>;
197
395
  /**
198
- * Generate a proof certificate for a specific operation.
396
+ * List the capsule's documents (metadata only). The bearer is returned ONCE by
397
+ * `add` and never stored — to build a portable file for a document, use that
398
+ * bearer with the /api/lockbox-container/portable route (controlled) or the
399
+ * /portable client flow (standalone). Both are per-document.
199
400
  */
200
- certificate(auditId: string): Promise<{
201
- success: boolean;
202
- certificate: {
203
- audit_id: string;
204
- proof_hash: string;
205
- merkle_root: string;
206
- timestamp: string;
207
- algorithm: string;
208
- };
209
- }>;
401
+ list(): Promise<ListDocumentsResponse>;
402
+ }
403
+ interface CapsuleMember {
404
+ email: string;
405
+ classifications: string[];
406
+ has_code: boolean;
407
+ in_conversation: boolean;
408
+ }
409
+ interface AddMemberRequest {
410
+ email: string;
411
+ classifications: string[];
412
+ /** Optional owner-chosen passphrase that opens ONLY this member's classifications. */
413
+ code?: string;
414
+ /** Also provision (lazily) the member's conversation rooms. */
415
+ add_to_conversation?: boolean;
416
+ }
417
+ interface AddMemberResponse {
418
+ ok: boolean;
419
+ capsule_id: string;
420
+ member: CapsuleMember;
421
+ recipient_code?: string;
422
+ }
423
+ interface ListMembersResponse {
424
+ ok: boolean;
425
+ capsule_id: string;
426
+ members: CapsuleMember[];
427
+ }
428
+ /** Member sub-resource on a capsule handle. */
429
+ declare class CapsuleMembers {
430
+ private http;
431
+ private ref;
432
+ constructor(http: HttpClient, ref: string);
433
+ /** Grant a member access across the capsule's documents (+ optional conversation). */
434
+ add(req: AddMemberRequest): Promise<AddMemberResponse>;
435
+ /** The unified roster (document ACL ∪ conversation membership). */
436
+ list(): Promise<ListMembersResponse>;
437
+ }
438
+ interface CapsuleOpen {
439
+ lockbox_file_id: string;
440
+ device_fp: string | null;
441
+ ip_hash: string | null;
442
+ result: string;
443
+ receipt_id: string | null;
444
+ observed_at: string;
445
+ }
446
+ interface CapsuleReceipt {
447
+ id: string;
448
+ chain_index: number | null;
449
+ event_type: string;
450
+ event_hash: string | null;
451
+ chain_hmac: string | null;
452
+ created_at: string;
453
+ payload: Record<string, unknown> | null;
454
+ }
455
+ interface CapsuleAuditResponse {
456
+ ok: boolean;
457
+ capsule_id: string;
458
+ documents: number;
459
+ counts: {
460
+ opens: number;
461
+ receipts: number;
462
+ denied: number;
463
+ };
464
+ opens: CapsuleOpen[];
465
+ receipts: CapsuleReceipt[];
466
+ verification: string;
467
+ }
468
+ /** Audit sub-resource on a capsule handle. */
469
+ declare class CapsuleAudit {
470
+ private http;
471
+ private ref;
472
+ constructor(http: HttpClient, ref: string);
473
+ /** The signed audit ledger: access log (who/when/device) + chain-linked receipts. */
474
+ get(opts?: {
475
+ from?: string;
476
+ to?: string;
477
+ limit?: number;
478
+ }): Promise<CapsuleAuditResponse>;
479
+ }
480
+ interface RevokeCapsuleResponse {
481
+ ok: boolean;
482
+ capsule_id: string;
483
+ status: 'revoked';
484
+ revoked_documents: string[];
485
+ sessions_revoked: number;
486
+ receipt_id: string | null;
487
+ key_kid_blocked: boolean;
488
+ customer_frozen: boolean;
489
+ capsule_marked: boolean;
490
+ }
491
+ interface CapsuleAiGrant {
492
+ agent_id: string;
493
+ agent_name: string;
494
+ allowed_classifications: string[];
495
+ denied_classifications: string[];
496
+ documents: number;
497
+ }
498
+ interface GrantAiResponse extends CapsuleAiGrant {
499
+ ok: boolean;
500
+ capsule_id: string;
501
+ }
502
+ interface ListAiGrantsResponse {
503
+ ok: boolean;
504
+ capsule_id: string;
505
+ agents: CapsuleAiGrant[];
506
+ }
507
+ interface RevokeAiGrantResponse {
508
+ ok: boolean;
509
+ capsule_id: string;
510
+ agent_id: string;
511
+ revoked_documents: string[];
512
+ }
513
+ interface AiReadSection {
514
+ label: string;
515
+ classification: string;
516
+ text: string;
517
+ }
518
+ interface AiReadDocument {
519
+ lockbox_id: string;
520
+ title: string | null;
521
+ key_mode: 'managed' | 'zero_knowledge';
522
+ /** Only the agent's ALLOWED classifications appear; denied sections never decrypt. */
523
+ sections: AiReadSection[];
524
+ note?: string;
525
+ }
526
+ interface AiReadResponse {
527
+ ok: boolean;
528
+ capsule_id: string;
529
+ agent_id: string;
530
+ allowed_classifications: string[];
531
+ documents: AiReadDocument[];
532
+ }
533
+ /**
534
+ * AI-governance sub-resource: grant a scoped agent, then let it read ONLY its
535
+ * allowed classifications (denied sections never decrypt — deny-by-default),
536
+ * with every read audited as an AI access.
537
+ * @example
538
+ * ```ts
539
+ * const g = await cap.ai.grant({ agent_name: 'claims-bot', classifications: ['public'] });
540
+ * const read = await cap.ai.read({ agent_id: g.agent_id }); // only 'public' sections come back
541
+ * await cap.ai.revoke(g.agent_id);
542
+ * ```
543
+ */
544
+ declare class CapsuleAi {
545
+ private http;
546
+ private ref;
547
+ constructor(http: HttpClient, ref: string);
548
+ /** Grant a named agent scoped classification access. Returns its agent_id. */
549
+ grant(req: {
550
+ agent_name: string;
551
+ classifications: string[];
552
+ }): Promise<GrantAiResponse>;
553
+ /** Live agent grants: who is allowed which classifications (and denied which). */
554
+ list(): Promise<ListAiGrantsResponse>;
555
+ /** Revoke an agent across the whole capsule. */
556
+ revoke(agentId: string): Promise<RevokeAiGrantResponse>;
557
+ /** The AI READ loop: the agent gets back ONLY its allowed classifications. */
558
+ read(req: {
559
+ agent_id: string;
560
+ document_id?: string;
561
+ }): Promise<AiReadResponse>;
562
+ }
563
+ interface EmbedTokenRequest {
564
+ /** A document bearer returned by documents.add (must belong to this capsule). */
565
+ bearer: string;
566
+ /** The EXACT https origin allowed to frame it, e.g. https://portal.myfirm.com. */
567
+ allowed_origin: string;
568
+ /** Token lifetime; default 3600s, max 30 days. */
569
+ ttl_seconds?: number;
570
+ }
571
+ interface EmbedTokenResponse {
572
+ ok: boolean;
573
+ capsule_id: string;
574
+ embed_token: string;
575
+ /** Point an <iframe> at this; the raw bearer never leaves NoData's origin. */
576
+ embed_url: string;
577
+ allowed_origin: string;
578
+ expires_at: string;
579
+ }
580
+ /** A live handle to one capsule — its summary plus chainable sub-resources. */
581
+ declare class Capsule {
582
+ private http;
583
+ readonly summary: CapsuleSummary;
584
+ readonly documents: CapsuleDocuments;
585
+ readonly members: CapsuleMembers;
586
+ readonly audit: CapsuleAudit;
587
+ readonly ai: CapsuleAi;
588
+ constructor(http: HttpClient, summary: CapsuleSummary);
589
+ get id(): string;
590
+ get slug(): string;
591
+ get status(): CapsuleStatus;
210
592
  /**
211
- * Verify a receipt/proof hash.
593
+ * Mint an origin-bound embed token for one of this capsule's documents, so you
594
+ * can frame the white-label viewer on your own site. The raw bearer stays on
595
+ * NoData's origin — the token encrypts it.
212
596
  */
213
- verify(proofHash: string): Promise<{
214
- success: boolean;
215
- valid: boolean;
216
- entry?: {
217
- action: string;
218
- field_name: string;
219
- created_at: string;
220
- };
221
- }>;
597
+ embed(req: EmbedTokenRequest): Promise<EmbedTokenResponse>;
598
+ /** Kill-switch: block the key, freeze the customer + sessions, revoke every doc. */
599
+ revoke(opts?: {
600
+ reason?: string;
601
+ }): Promise<RevokeCapsuleResponse>;
602
+ }
603
+ declare class CapsuleModule {
604
+ private http;
605
+ constructor(http: HttpClient);
606
+ /**
607
+ * Mint a customer capsule (a vault is born). Returns a Capsule handle.
608
+ * @example
609
+ * ```ts
610
+ * const cap = await nd.capsules.create({ handle: 'case-4471', display_name: 'Yossi Levy' });
611
+ * ```
612
+ */
613
+ create(req: CreateCapsuleRequest): Promise<Capsule>;
614
+ /** Fetch a capsule handle by slug or id. */
615
+ get(idOrSlug: string): Promise<Capsule>;
616
+ /** List this org's active capsules (newest first). */
617
+ list(opts?: {
618
+ limit?: number;
619
+ }): Promise<ListCapsulesResponse>;
620
+ /**
621
+ * Fleet aggregates for the Control Plane — you manage a fleet, not a capsule:
622
+ * active/frozen/revoked vaults, documents, 24h activity, and AI governance totals.
623
+ */
624
+ overview(): Promise<OverviewResponse>;
625
+ }
626
+ interface OverviewResponse {
627
+ ok: boolean;
628
+ org_id: string;
629
+ fleet: {
630
+ active_vaults: number;
631
+ frozen_vaults: number;
632
+ revoked_vaults: number;
633
+ total_documents: number;
634
+ };
635
+ activity_24h: {
636
+ opens: number;
637
+ denied: number;
638
+ };
639
+ lifetime: {
640
+ access_decisions: number;
641
+ ai_requests: number;
642
+ revocations: number;
643
+ };
644
+ ai_governance: {
645
+ agents: number;
646
+ grants_active: number;
647
+ };
222
648
  }
223
649
 
224
- declare class VaultModule {
650
+ interface CreateTenantRequest {
651
+ company_name: string;
652
+ /** /^[a-z0-9-]{3,64}$/ — unique across NoData. */
653
+ slug: string;
654
+ tier?: string;
655
+ currency?: string;
656
+ contact_email?: string;
657
+ master_key_location?: 'cloud_vault' | 'on_prem' | 'hybrid';
658
+ pii_storage_mode?: 'cloud_vault' | 'on_prem' | 'hybrid';
659
+ /** If true, mint a Capsule install token in the same call. */
660
+ capsule_install?: boolean;
661
+ }
662
+ interface CreateTenantResponse {
663
+ ok: boolean;
664
+ tenant_id: string;
665
+ tenant_console_url: string;
666
+ m365_install_url: string;
667
+ capsule_install_token: string | null;
668
+ capsule_install_token_expires_at: string | null;
669
+ receipt_id: string | null;
670
+ }
671
+ interface TenantState {
672
+ tenant: {
673
+ id: string;
674
+ name: string;
675
+ slug: string;
676
+ tier: string;
677
+ active: boolean;
678
+ kill_switch_state: string;
679
+ master_key_location: string;
680
+ pii_storage_mode: string;
681
+ created_at: string;
682
+ };
683
+ m365: {
684
+ status: string;
685
+ consent_granted_at: string | null;
686
+ } | null;
687
+ capsule: {
688
+ deployments: Array<Record<string, unknown>>;
689
+ last_scan_at: string | null;
690
+ open_findings_count: number;
691
+ };
692
+ }
693
+ declare class TenantModule {
225
694
  private http;
226
695
  constructor(http: HttpClient);
227
696
  /**
228
- * Store an encrypted blob in the vault.
229
- * YOU encrypt client-side. Server stores blindly.
230
- *
697
+ * Provision a tenant (a whole org) programmatically. Requires a key with the
698
+ * `partner.provision_tenants` scope.
231
699
  * @example
232
700
  * ```ts
233
- * // Encrypt client-side, then store
234
- * const blob = myEncrypt(sensitiveData, myKey);
235
- * const vault = await nd.vault.create({
236
- * label: "customer-contracts",
237
- * encrypted_blob: blob.ciphertext,
238
- * iv: blob.iv,
239
- * metadata: { customer_id: "cust_123" },
240
- * });
701
+ * const t = await nd.tenants.create({ company_name: 'Acme', slug: 'acme', capsule_install: true });
241
702
  * ```
242
703
  */
243
- create(req: VaultCreateRequest): Promise<VaultCreateResponse>;
704
+ create(req: CreateTenantRequest): Promise<CreateTenantResponse>;
705
+ /** Read a tenant's state (M365 connection, capsule deployments, open findings). */
706
+ get(tenantId: string): Promise<TenantState>;
707
+ }
708
+
709
+ type ScanSource = 'folder' | 'drive' | 'db' | 's3';
710
+ interface EnableScanRequest {
711
+ /** Where to scan — all scanning happens locally on the agent's machine. */
712
+ source: ScanSource;
713
+ /** Local folder path (source='folder'). */
714
+ path?: string;
715
+ /** Drive folder id (source='drive'). */
716
+ folder_id?: string;
717
+ /** How to group documents into customer capsules (e.g. 'folder' = one per folder). */
718
+ per_customer?: string;
719
+ /** Override the agent's API base (defaults to the SDK baseUrl). */
720
+ api_base?: string;
721
+ }
722
+ interface EnableScanResponse {
723
+ ok: boolean;
724
+ /** Opaque scan handle (prefix of the install token). */
725
+ scan_id: string;
726
+ /** One-shot install token — shown once; enrol the agent with it. */
727
+ install_token: string;
728
+ /** Copy-paste command to run the LOCAL scan agent. */
729
+ install_command: string;
730
+ /** When the install token expires. */
731
+ expires_at: string | null;
732
+ }
733
+ interface ScanDeployment {
734
+ id: string;
735
+ status: string;
736
+ last_seen_at: string | null;
737
+ last_scan_at: string | null;
738
+ agent_version: string;
739
+ }
740
+ interface ScanStatus {
741
+ deployments: ScanDeployment[];
742
+ last_scan_at: string | null;
743
+ /** Content-free: how many sensitive-field findings the local scan surfaced. */
744
+ open_findings_count: number;
745
+ }
746
+ /**
747
+ * nd.scan — populate capsules from a LOCAL, content-blind scan.
748
+ * @example
749
+ * ```ts
750
+ * const scan = await nd.scan.enable({ source: 'folder', path: './customers', per_customer: 'folder' });
751
+ * console.log(scan.install_command); // run this — the agent scans locally, no data leaves
752
+ * const status = await nd.scan.status();
753
+ * ```
754
+ */
755
+ declare class ScanModule {
756
+ private http;
757
+ constructor(http: HttpClient);
758
+ private orgId;
244
759
  /**
245
- * Retrieve an encrypted blob from the vault.
246
- * YOU decrypt client-side.
760
+ * Enable a LOCAL scan agent over your data. Mints a one-shot install token and
761
+ * returns the command to run the agent — which generates its own keys locally,
762
+ * scans with deterministic code (no LLM), and reports content-free findings.
763
+ * Nothing (data or keys) leaves your machine.
247
764
  */
248
- read(vaultId: string): Promise<VaultReadResponse>;
765
+ enable(req: EnableScanRequest): Promise<EnableScanResponse>;
766
+ /** Poll the local agent's status + how many content-free findings it surfaced. */
767
+ status(): Promise<ScanStatus>;
249
768
  /**
250
- * Delete a vault entry (irreversible).
769
+ * The local scan's content-free conclusions: per finding, the source/field, its
770
+ * kind/severity, and a RECOMMENDED classification (never a value). You approve
771
+ * these before anything is sealed — the capsule only recommends.
251
772
  */
252
- delete(vaultId: string): Promise<{
253
- success: boolean;
773
+ findings(opts?: {
774
+ limit?: number;
775
+ all?: boolean;
776
+ }): Promise<ScanFindingsResponse>;
777
+ /**
778
+ * Adopt the recommendations for the given findings — the legal record that you
779
+ * (not the machine) chose each policy. Writes a content-free signed receipt.
780
+ * Nothing is sealed here; dispatch approved files with `execute`.
781
+ */
782
+ approve(findingIds: string[]): Promise<{
783
+ ok: boolean;
784
+ approved: number;
785
+ receipt_id: string | null;
254
786
  }>;
255
787
  /**
256
- * Check vault service status.
788
+ * Dispatch APPROVED files for sealing — queues each file for the local agent to
789
+ * seal into its capsule with the approved classification. Only findings you've
790
+ * already approved can be dispatched.
257
791
  */
258
- status(): Promise<{
792
+ execute(findingIds: string[]): Promise<{
793
+ ok: boolean;
794
+ dispatched: number;
795
+ files: Array<{
796
+ target_id: string;
797
+ label: string | null;
798
+ path: string | null;
799
+ }>;
800
+ }>;
801
+ }
802
+ interface ScanFinding {
803
+ id: string;
804
+ source: string | null;
805
+ field: string | null;
806
+ kind: string | null;
807
+ subkind: string | null;
808
+ severity: string | null;
809
+ count: number;
810
+ /** Suggested classification — you approve or override it. */
811
+ recommended: string;
812
+ reason: string;
813
+ approved: boolean;
814
+ target_id: string | null;
815
+ first_seen_at: string | null;
816
+ }
817
+ interface ScanFindingsResponse {
818
+ ok: boolean;
819
+ count: number;
820
+ findings: ScanFinding[];
821
+ }
822
+
823
+ declare class EncryptModule {
824
+ private http;
825
+ constructor(http: HttpClient);
826
+ /**
827
+ * Encrypt a single field value.
828
+ * Server encrypts with AES-256-GCM and returns ciphertext + key material.
829
+ * Store the result in YOUR database — NoData stores nothing.
830
+ */
831
+ encrypt(req: EncryptRequest): Promise<EncryptResponse>;
832
+ /**
833
+ * Decrypt a single field value.
834
+ * Requires the ciphertext that was returned from encrypt().
835
+ */
836
+ decrypt(req: DecryptRequest): Promise<DecryptResponse>;
837
+ /**
838
+ * Encrypt multiple fields in parallel.
839
+ * Failed fields don't block successful ones.
840
+ */
841
+ batchEncrypt(fields: EncryptRequest[], context?: string): Promise<BatchResult<EncryptResponse>>;
842
+ /**
843
+ * Decrypt multiple fields in parallel.
844
+ */
845
+ batchDecrypt(fields: DecryptRequest[], requester?: string): Promise<BatchResult<DecryptResponse>>;
846
+ /**
847
+ * Native batch — single HTTP call for up to 100 encrypt/decrypt operations.
848
+ * More efficient than batchEncrypt/batchDecrypt for large batches.
849
+ */
850
+ batchNative(items: Array<{
851
+ op: 'encrypt';
852
+ field: string;
853
+ value: string;
854
+ } | {
855
+ op: 'decrypt';
856
+ field: string;
857
+ ciphertext: string;
858
+ }>, context?: string): Promise<{
259
859
  success: boolean;
260
- vault_count: number;
261
- storage_used_bytes: number;
860
+ batch_id: string;
861
+ results: Array<{
862
+ op: string;
863
+ field: string;
864
+ success: boolean;
865
+ ciphertext?: string;
866
+ value?: string;
867
+ audit_id?: string;
868
+ error?: string;
869
+ }>;
870
+ ok: number;
871
+ failed: number;
262
872
  }>;
873
+ /**
874
+ * Encrypt all matching fields in a plain object.
875
+ * Walks nested objects and arrays.
876
+ *
877
+ * @example
878
+ * ```ts
879
+ * const encrypted = await nd.encryptObject(
880
+ * { name: "David", phone: "0501234567", email: "d@x.com", age: 30 },
881
+ * ["phone", "email"]
882
+ * );
883
+ * // → { name: "David", phone: "aes256gcm:v1:...", email: "aes256gcm:v1:...", age: 30 }
884
+ * ```
885
+ */
886
+ encryptObject(obj: Record<string, unknown>, fields: string[], context?: string): Promise<Record<string, unknown>>;
887
+ /**
888
+ * Decrypt all matching fields in an encrypted object.
889
+ */
890
+ decryptObject(obj: Record<string, unknown>, fields: string[], requester?: string): Promise<Record<string, unknown>>;
891
+ private processObject;
892
+ }
893
+
894
+ /** The platform engines, namespaced away from the Customer Vault surface. */
895
+ declare class EnginesModule {
896
+ /** Governance Engine — AI/data permission management (register data, grant, revoke). Runs on Excel/DB/CRM/Agent, not only capsules. */
897
+ readonly governance: GovernanceModule;
898
+ /** Blind Relay Engine — field-level encrypt / decrypt / batch (server stores nothing). */
899
+ readonly blindRelay: EncryptModule;
900
+ /** Channel Engine — system-to-system encrypted transfer. */
901
+ readonly channel: ChannelModule;
902
+ /** Delivery — burn-after-read secure delivery. */
903
+ readonly deliver: DeliverModule;
904
+ /** Evidence — audit trail + cryptographic proofs. */
905
+ readonly evidence: EvidenceModule;
906
+ /** Vault — zero-knowledge encrypted storage. */
907
+ readonly vault: VaultModule;
908
+ /** Webhooks — receive external webhooks through encrypted channels. */
909
+ readonly webhook: WebhookModule;
910
+ constructor(http: HttpClient);
911
+ }
912
+
913
+ declare class ComputeEngine {
914
+ private http;
915
+ constructor(http: HttpClient);
916
+ /** Run the primitive: information + intent → { decision, answer, authorized view, proof }. */
917
+ run(req: ComputeRequest): Promise<ComputeDecision>;
918
+ /** Prove verb: given a decision proof id, confirm it is authentic + unaltered. */
919
+ verify(proofId: string): Promise<VerifyResult>;
263
920
  }
264
921
 
265
922
  declare class NoData {
266
923
  private http;
267
924
  private _encrypt;
268
- /** Secure channels — system-to-system encrypted transfer */
269
- channel: ChannelModule;
270
- /** Webhooks — receive external webhooks through encrypted channels */
271
- webhook: WebhookModule;
272
- /** Delivery — burn-after-read secure delivery */
273
- deliver: DeliverModule;
274
- /** Evidence — audit trail + cryptographic proofs */
275
- evidence: EvidenceModule;
276
- /** Vault — zero-knowledge encrypted storage */
277
- vault: VaultModule;
925
+ /** Capsules — an isolated customer workspace (documents + members + AI grants + audit) as an API. */
926
+ capsules: CapsuleModule;
927
+ /** Tenants — provision a whole organization programmatically. */
928
+ tenants: TenantModule;
929
+ /** Scan — enable a LOCAL, content-blind scan (no LLM) that populates capsules. You approve every policy. */
930
+ scan: ScanModule;
931
+ /** Platform engines (governance, blind-relay, channel, delivery, evidence, vault, webhooks). Advanced / "Powered by". */
932
+ engines: EnginesModule;
933
+ private _compute;
278
934
  constructor(config: NoDataConfig);
279
- /** Encrypt a single field (blind relay — server stores nothing) */
935
+ /**
936
+ * THE primitive. Hand NoData the information + the intent + the clearance;
937
+ * get back the decision, the answer over ONLY the authorized slice, and a
938
+ * signed proof.
939
+ *
940
+ * const { answer, proof } = await nd.compute({
941
+ * question: 'What is the claim status?',
942
+ * clearance: 'internal',
943
+ * sections: [{ title: 'Status', text: '…' }, { title: 'Client', text: '…' }],
944
+ * });
945
+ */
946
+ compute(req: ComputeRequest): Promise<ComputeDecision>;
947
+ /** The Prove verb: confirm a decision proof is authentic + unaltered, without decrypting anything. */
948
+ verify(proofId: string): Promise<VerifyResult>;
949
+ /** @deprecated use `nd.engines.channel` */
950
+ get channel(): ChannelModule;
951
+ /** @deprecated use `nd.engines.webhook` */
952
+ get webhook(): WebhookModule;
953
+ /** @deprecated use `nd.engines.deliver` */
954
+ get deliver(): DeliverModule;
955
+ /** @deprecated use `nd.engines.evidence` */
956
+ get evidence(): EvidenceModule;
957
+ /** @deprecated use `nd.engines.vault` */
958
+ get vault(): VaultModule;
959
+ /** @deprecated use `nd.engines.governance` */
960
+ get governance(): GovernanceModule;
961
+ /**
962
+ * Bind to an agent grant token to read governed data AS that agent.
963
+ * Authenticates with the grant token (not your API key) — exactly what
964
+ * an LLM/agent runtime holds. Denied columns never decrypt server-side.
965
+ */
966
+ agent(grantToken: string): AgentReader;
967
+ /** @deprecated Blind-Relay is a platform engine — use `nd.engines.blindRelay.encrypt`. */
280
968
  encrypt(req: EncryptRequest): Promise<EncryptResponse>;
281
- /** Decrypt a single field */
969
+ /** @deprecated Blind-Relay is a platform engine — use `nd.engines.blindRelay.decrypt`. */
282
970
  decrypt(req: DecryptRequest): Promise<DecryptResponse>;
283
971
  /** Encrypt multiple fields in parallel */
284
972
  batchEncrypt(fields: EncryptRequest[], context?: string): Promise<BatchResult<EncryptResponse>>;
@@ -319,4 +1007,4 @@ declare class NoData {
319
1007
  }>;
320
1008
  }
321
1009
 
322
- export { BatchResult, ChannelCreateRequest, ChannelCreateResponse, ChannelReceiveRequest, ChannelReceiveResponse, ChannelSendRequest, ChannelSendResponse, DecryptRequest, DecryptResponse, DeliverRequest, DeliverResponse, EncryptRequest, EncryptResponse, EvidenceQuery, EvidenceResponse, NoData, NoDataConfig, VaultCreateRequest, VaultCreateResponse, VaultReadResponse, WebhookChannelCreateRequest, WebhookChannelCreateResponse, WebhookEventsResponse };
1010
+ export { type AddDocumentRequest, type AddDocumentResponse, type AddMemberRequest, type AddMemberResponse, AgentReadRequest, AgentReadResponse, AgentReader, type AiReadDocument, type AiReadResponse, type AiReadSection, BatchResult, Capsule, CapsuleAi, type CapsuleAiGrant, CapsuleAudit, type CapsuleAuditResponse, CapsuleDocuments, type CapsuleKeyMode, type CapsuleMember, CapsuleMembers, CapsuleModule, type CapsuleOpen, type CapsuleReceipt, type CapsuleStatus, type CapsuleSummary, ChannelCreateRequest, ChannelCreateResponse, ChannelReceiveRequest, ChannelReceiveResponse, ChannelSendRequest, ChannelSendResponse, ComputeDecision, ComputeEngine, ComputeRequest, type CreateCapsuleRequest, type CreateTenantRequest, type CreateTenantResponse, DecryptRequest, DecryptResponse, DeliverRequest, DeliverResponse, type DocumentRecipient, type DocumentSection, type DocumentSummary, type EmbedTokenRequest, type EmbedTokenResponse, type EnableScanRequest, type EnableScanResponse, EncryptRequest, EncryptResponse, EnginesModule, EvidenceQuery, EvidenceResponse, GovernanceModule, type GrantAiResponse, GrantRequest, GrantResponse, type ListAiGrantsResponse, type ListCapsulesResponse, type ListDocumentsResponse, type ListMembersResponse, NoData, NoDataConfig, type OverviewResponse, type PortableMode, RegisterTableRequest, RegisterTableResponse, type RevokeAiGrantResponse, type RevokeCapsuleResponse, RevokeRequest, RevokeResponse, type ScanDeployment, type ScanFinding, type ScanFindingsResponse, ScanModule, type ScanSource, type ScanStatus, TenantModule, type TenantState, VaultCreateRequest, VaultCreateResponse, VaultReadResponse, VerifyResult, WebhookChannelCreateRequest, WebhookChannelCreateResponse, WebhookEventsResponse };