@nodatachat/sdk 1.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/README.md +385 -0
- package/dist/chunk-V6GUTSNO.mjs +601 -0
- package/dist/index.d.mts +322 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.js +628 -0
- package/dist/index.mjs +8 -0
- package/dist/plugins/express.d.mts +20 -0
- package/dist/plugins/express.d.ts +20 -0
- package/dist/plugins/express.js +663 -0
- package/dist/plugins/express.mjs +43 -0
- package/dist/plugins/fastify.d.mts +11 -0
- package/dist/plugins/fastify.d.ts +11 -0
- package/dist/plugins/fastify.js +667 -0
- package/dist/plugins/fastify.mjs +47 -0
- package/dist/types-DQh0UmSr.d.mts +233 -0
- package/dist/types-DQh0UmSr.d.ts +233 -0
- package/package.json +64 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NoData
|
|
3
|
+
} from "../chunk-V6GUTSNO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/plugins/fastify.ts
|
|
6
|
+
function nodataFastify(fastify, config, done) {
|
|
7
|
+
const nd = new NoData({ apiKey: config.apiKey, baseUrl: config.baseUrl });
|
|
8
|
+
const encryptFields = config.encryptFields || [];
|
|
9
|
+
const decryptFields = config.decryptFields || [];
|
|
10
|
+
const skipPaths = config.skipPaths || [];
|
|
11
|
+
if (decryptFields.length > 0) {
|
|
12
|
+
fastify.addHook("preHandler", async (request) => {
|
|
13
|
+
if (skipPaths.some((p) => request.url.startsWith(p))) return;
|
|
14
|
+
if (!request.body || typeof request.body !== "object") return;
|
|
15
|
+
if (request.method === "GET") return;
|
|
16
|
+
const shouldDecrypt = !config.decryptHeader || request.headers[config.decryptHeader.toLowerCase()];
|
|
17
|
+
if (shouldDecrypt) {
|
|
18
|
+
try {
|
|
19
|
+
request.body = await nd.decryptObject(
|
|
20
|
+
request.body,
|
|
21
|
+
decryptFields,
|
|
22
|
+
request.headers["x-requester"] || "fastify-plugin"
|
|
23
|
+
);
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (encryptFields.length > 0) {
|
|
30
|
+
fastify.addHook("onSend", async (_request, _reply, payload) => {
|
|
31
|
+
if (typeof payload !== "string") return payload;
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(payload);
|
|
34
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
35
|
+
const encrypted = await nd.encryptObject(parsed, encryptFields, config.context);
|
|
36
|
+
return JSON.stringify(encrypted);
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return payload;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
done();
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
nodataFastify
|
|
47
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
interface NoDataConfig {
|
|
2
|
+
/** API key (sk_live_...) — get from https://www.nodatachat.com/developers */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Base URL (default: https://www.nodatachat.com) */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Timeout in ms (default: 30000) */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
/** Max retries on 5xx or network errors (default: 2) */
|
|
9
|
+
retries?: number;
|
|
10
|
+
/** Custom headers added to every request */
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
/** Hook: called before every request */
|
|
13
|
+
onRequest?: (url: string, init: RequestInit) => void;
|
|
14
|
+
/** Hook: called on every response */
|
|
15
|
+
onResponse?: (url: string, status: number, durationMs: number) => void;
|
|
16
|
+
/** Hook: called on error */
|
|
17
|
+
onError?: (url: string, error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface EncryptRequest {
|
|
20
|
+
/** Field name (e.g., "credit_card", "ssn", "email") */
|
|
21
|
+
field: string;
|
|
22
|
+
/** Plaintext value to encrypt */
|
|
23
|
+
value: string;
|
|
24
|
+
/** Context for audit trail (e.g., "checkout_flow") */
|
|
25
|
+
context?: string;
|
|
26
|
+
}
|
|
27
|
+
interface EncryptResponse {
|
|
28
|
+
success: boolean;
|
|
29
|
+
/** Encrypted ciphertext — store this in YOUR database */
|
|
30
|
+
ciphertext: string;
|
|
31
|
+
field: string;
|
|
32
|
+
audit_id: string;
|
|
33
|
+
algorithm: string;
|
|
34
|
+
}
|
|
35
|
+
interface DecryptRequest {
|
|
36
|
+
/** Ciphertext to decrypt */
|
|
37
|
+
ciphertext: string;
|
|
38
|
+
/** Field name */
|
|
39
|
+
field: string;
|
|
40
|
+
/** Who is requesting (for audit) */
|
|
41
|
+
requester?: string;
|
|
42
|
+
/** Purpose (for audit) */
|
|
43
|
+
purpose?: string;
|
|
44
|
+
}
|
|
45
|
+
interface DecryptResponse {
|
|
46
|
+
success: boolean;
|
|
47
|
+
value: string;
|
|
48
|
+
field: string;
|
|
49
|
+
audit_id: string;
|
|
50
|
+
}
|
|
51
|
+
interface BatchResult<T> {
|
|
52
|
+
success: boolean;
|
|
53
|
+
results: T[];
|
|
54
|
+
/** Number of successful operations */
|
|
55
|
+
ok: number;
|
|
56
|
+
/** Number of failed operations */
|
|
57
|
+
failed: number;
|
|
58
|
+
}
|
|
59
|
+
interface ChannelCreateRequest {
|
|
60
|
+
/** Human-readable label */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** Channel TTL (e.g., "1h", "24h", "7d") */
|
|
63
|
+
ttl?: string;
|
|
64
|
+
/** Max number of transfers */
|
|
65
|
+
maxTransfers?: number;
|
|
66
|
+
/** Require verification code */
|
|
67
|
+
requireVerification?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ChannelCreateResponse {
|
|
70
|
+
success: boolean;
|
|
71
|
+
channel_id: string;
|
|
72
|
+
channel_token: string;
|
|
73
|
+
verification_code?: string;
|
|
74
|
+
expires_at: string;
|
|
75
|
+
}
|
|
76
|
+
interface ChannelSendRequest {
|
|
77
|
+
/** Channel token */
|
|
78
|
+
token: string;
|
|
79
|
+
/** Data to send (will be encrypted) */
|
|
80
|
+
data: string | Record<string, unknown>;
|
|
81
|
+
/** Content type hint */
|
|
82
|
+
contentType?: string;
|
|
83
|
+
/** Burn after read */
|
|
84
|
+
burnAfterRead?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface ChannelSendResponse {
|
|
87
|
+
success: boolean;
|
|
88
|
+
transfer_id: string;
|
|
89
|
+
proof_hash: string;
|
|
90
|
+
}
|
|
91
|
+
interface ChannelReceiveRequest {
|
|
92
|
+
/** Channel token */
|
|
93
|
+
token: string;
|
|
94
|
+
/** Verification code (if required) */
|
|
95
|
+
verificationCode?: string;
|
|
96
|
+
}
|
|
97
|
+
interface ChannelReceiveResponse {
|
|
98
|
+
success: boolean;
|
|
99
|
+
data: string;
|
|
100
|
+
content_type: string;
|
|
101
|
+
transfer_id: string;
|
|
102
|
+
proof_hash: string;
|
|
103
|
+
sender_proof: string;
|
|
104
|
+
}
|
|
105
|
+
interface WebhookChannelCreateRequest {
|
|
106
|
+
/** Human-readable label */
|
|
107
|
+
label?: string;
|
|
108
|
+
/** Channel TTL (e.g., "24h", "7d", "30d") */
|
|
109
|
+
ttl?: string;
|
|
110
|
+
/** Max number of events before channel closes */
|
|
111
|
+
maxEvents?: number;
|
|
112
|
+
/** Burn events after read */
|
|
113
|
+
burnAfterRead?: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface WebhookChannelCreateResponse {
|
|
116
|
+
success: boolean;
|
|
117
|
+
channel_id: string;
|
|
118
|
+
/** The token to use in the webhook URL */
|
|
119
|
+
channel_token: string;
|
|
120
|
+
/** The secret for client-side decryption */
|
|
121
|
+
secret: string;
|
|
122
|
+
/** Full ingest URL: POST to this from your system */
|
|
123
|
+
ingest_url: string;
|
|
124
|
+
expires_at: string;
|
|
125
|
+
}
|
|
126
|
+
interface WebhookEvent {
|
|
127
|
+
id: string;
|
|
128
|
+
encrypted_blob: string;
|
|
129
|
+
iv: string;
|
|
130
|
+
source_ip_hash: string;
|
|
131
|
+
http_method: string;
|
|
132
|
+
content_type: string;
|
|
133
|
+
created_at: string;
|
|
134
|
+
}
|
|
135
|
+
interface WebhookEventsResponse {
|
|
136
|
+
success: boolean;
|
|
137
|
+
events: WebhookEvent[];
|
|
138
|
+
remaining: number;
|
|
139
|
+
}
|
|
140
|
+
interface DeliverRequest {
|
|
141
|
+
/** Content to deliver */
|
|
142
|
+
content: string;
|
|
143
|
+
/** Recipient identifier (optional) */
|
|
144
|
+
to?: string;
|
|
145
|
+
/** TTL (e.g., "5m", "1h", "24h") */
|
|
146
|
+
ttl?: string;
|
|
147
|
+
/** Self-destruct after read */
|
|
148
|
+
burn?: boolean;
|
|
149
|
+
/** Max number of views */
|
|
150
|
+
maxViews?: number;
|
|
151
|
+
}
|
|
152
|
+
interface DeliverResponse {
|
|
153
|
+
success: boolean;
|
|
154
|
+
delivery_id: string;
|
|
155
|
+
/** URL for recipient to open */
|
|
156
|
+
delivery_url: string;
|
|
157
|
+
/** Short code for SMS/voice */
|
|
158
|
+
code?: string;
|
|
159
|
+
expires_at: string;
|
|
160
|
+
proof_hash: string;
|
|
161
|
+
}
|
|
162
|
+
interface EvidenceQuery {
|
|
163
|
+
/** Start date (ISO 8601) */
|
|
164
|
+
from?: string;
|
|
165
|
+
/** End date (ISO 8601) */
|
|
166
|
+
to?: string;
|
|
167
|
+
/** Action type filter */
|
|
168
|
+
action?: string;
|
|
169
|
+
/** Field name filter */
|
|
170
|
+
field?: string;
|
|
171
|
+
/** Max results (default: 100) */
|
|
172
|
+
limit?: number;
|
|
173
|
+
}
|
|
174
|
+
interface EvidenceEntry {
|
|
175
|
+
id: string;
|
|
176
|
+
action: string;
|
|
177
|
+
field_name: string;
|
|
178
|
+
record_type: string;
|
|
179
|
+
proof_hash: string;
|
|
180
|
+
created_at: string;
|
|
181
|
+
}
|
|
182
|
+
interface EvidenceResponse {
|
|
183
|
+
success: boolean;
|
|
184
|
+
entries: EvidenceEntry[];
|
|
185
|
+
total: number;
|
|
186
|
+
}
|
|
187
|
+
interface VaultCreateRequest {
|
|
188
|
+
/** Label for the vault entry */
|
|
189
|
+
label: string;
|
|
190
|
+
/** Pre-encrypted blob (client-side encryption) */
|
|
191
|
+
encrypted_blob: string;
|
|
192
|
+
/** IV used for encryption */
|
|
193
|
+
iv: string;
|
|
194
|
+
/** Metadata (never encrypted by server) */
|
|
195
|
+
metadata?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
interface VaultCreateResponse {
|
|
198
|
+
success: boolean;
|
|
199
|
+
vault_id: string;
|
|
200
|
+
}
|
|
201
|
+
interface VaultReadResponse {
|
|
202
|
+
success: boolean;
|
|
203
|
+
vault_id: string;
|
|
204
|
+
encrypted_blob: string;
|
|
205
|
+
iv: string;
|
|
206
|
+
label: string;
|
|
207
|
+
metadata?: Record<string, unknown>;
|
|
208
|
+
created_at: string;
|
|
209
|
+
}
|
|
210
|
+
interface PluginConfig {
|
|
211
|
+
/** NoData API key */
|
|
212
|
+
apiKey: string;
|
|
213
|
+
/** Base URL */
|
|
214
|
+
baseUrl?: string;
|
|
215
|
+
/** Fields to auto-encrypt in responses */
|
|
216
|
+
encryptFields?: string[];
|
|
217
|
+
/** Fields to auto-decrypt in requests */
|
|
218
|
+
decryptFields?: string[];
|
|
219
|
+
/** Header that must be present for decryption (security gate) */
|
|
220
|
+
decryptHeader?: string;
|
|
221
|
+
/** Paths to skip (glob patterns) */
|
|
222
|
+
skipPaths?: string[];
|
|
223
|
+
/** Audit context */
|
|
224
|
+
context?: string;
|
|
225
|
+
}
|
|
226
|
+
declare class NoDataError extends Error {
|
|
227
|
+
status: number;
|
|
228
|
+
code?: string | undefined;
|
|
229
|
+
retryAfter?: number | undefined;
|
|
230
|
+
constructor(message: string, status: number, code?: string | undefined, retryAfter?: number | undefined);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { type BatchResult as B, type ChannelCreateRequest as C, type DeliverRequest as D, type EvidenceQuery as E, type NoDataConfig as N, type PluginConfig as P, type VaultCreateRequest as V, type WebhookChannelCreateRequest as W, type ChannelCreateResponse as a, type ChannelSendRequest as b, type ChannelSendResponse as c, type ChannelReceiveRequest as d, type ChannelReceiveResponse as e, type WebhookChannelCreateResponse as f, type WebhookEventsResponse as g, type DeliverResponse as h, type EvidenceResponse as i, type VaultCreateResponse as j, type VaultReadResponse as k, type EncryptRequest as l, type EncryptResponse as m, type DecryptRequest as n, type DecryptResponse as o, type EvidenceEntry as p, NoDataError as q, type WebhookEvent as r };
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
interface NoDataConfig {
|
|
2
|
+
/** API key (sk_live_...) — get from https://www.nodatachat.com/developers */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Base URL (default: https://www.nodatachat.com) */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Timeout in ms (default: 30000) */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
/** Max retries on 5xx or network errors (default: 2) */
|
|
9
|
+
retries?: number;
|
|
10
|
+
/** Custom headers added to every request */
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
/** Hook: called before every request */
|
|
13
|
+
onRequest?: (url: string, init: RequestInit) => void;
|
|
14
|
+
/** Hook: called on every response */
|
|
15
|
+
onResponse?: (url: string, status: number, durationMs: number) => void;
|
|
16
|
+
/** Hook: called on error */
|
|
17
|
+
onError?: (url: string, error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface EncryptRequest {
|
|
20
|
+
/** Field name (e.g., "credit_card", "ssn", "email") */
|
|
21
|
+
field: string;
|
|
22
|
+
/** Plaintext value to encrypt */
|
|
23
|
+
value: string;
|
|
24
|
+
/** Context for audit trail (e.g., "checkout_flow") */
|
|
25
|
+
context?: string;
|
|
26
|
+
}
|
|
27
|
+
interface EncryptResponse {
|
|
28
|
+
success: boolean;
|
|
29
|
+
/** Encrypted ciphertext — store this in YOUR database */
|
|
30
|
+
ciphertext: string;
|
|
31
|
+
field: string;
|
|
32
|
+
audit_id: string;
|
|
33
|
+
algorithm: string;
|
|
34
|
+
}
|
|
35
|
+
interface DecryptRequest {
|
|
36
|
+
/** Ciphertext to decrypt */
|
|
37
|
+
ciphertext: string;
|
|
38
|
+
/** Field name */
|
|
39
|
+
field: string;
|
|
40
|
+
/** Who is requesting (for audit) */
|
|
41
|
+
requester?: string;
|
|
42
|
+
/** Purpose (for audit) */
|
|
43
|
+
purpose?: string;
|
|
44
|
+
}
|
|
45
|
+
interface DecryptResponse {
|
|
46
|
+
success: boolean;
|
|
47
|
+
value: string;
|
|
48
|
+
field: string;
|
|
49
|
+
audit_id: string;
|
|
50
|
+
}
|
|
51
|
+
interface BatchResult<T> {
|
|
52
|
+
success: boolean;
|
|
53
|
+
results: T[];
|
|
54
|
+
/** Number of successful operations */
|
|
55
|
+
ok: number;
|
|
56
|
+
/** Number of failed operations */
|
|
57
|
+
failed: number;
|
|
58
|
+
}
|
|
59
|
+
interface ChannelCreateRequest {
|
|
60
|
+
/** Human-readable label */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** Channel TTL (e.g., "1h", "24h", "7d") */
|
|
63
|
+
ttl?: string;
|
|
64
|
+
/** Max number of transfers */
|
|
65
|
+
maxTransfers?: number;
|
|
66
|
+
/** Require verification code */
|
|
67
|
+
requireVerification?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ChannelCreateResponse {
|
|
70
|
+
success: boolean;
|
|
71
|
+
channel_id: string;
|
|
72
|
+
channel_token: string;
|
|
73
|
+
verification_code?: string;
|
|
74
|
+
expires_at: string;
|
|
75
|
+
}
|
|
76
|
+
interface ChannelSendRequest {
|
|
77
|
+
/** Channel token */
|
|
78
|
+
token: string;
|
|
79
|
+
/** Data to send (will be encrypted) */
|
|
80
|
+
data: string | Record<string, unknown>;
|
|
81
|
+
/** Content type hint */
|
|
82
|
+
contentType?: string;
|
|
83
|
+
/** Burn after read */
|
|
84
|
+
burnAfterRead?: boolean;
|
|
85
|
+
}
|
|
86
|
+
interface ChannelSendResponse {
|
|
87
|
+
success: boolean;
|
|
88
|
+
transfer_id: string;
|
|
89
|
+
proof_hash: string;
|
|
90
|
+
}
|
|
91
|
+
interface ChannelReceiveRequest {
|
|
92
|
+
/** Channel token */
|
|
93
|
+
token: string;
|
|
94
|
+
/** Verification code (if required) */
|
|
95
|
+
verificationCode?: string;
|
|
96
|
+
}
|
|
97
|
+
interface ChannelReceiveResponse {
|
|
98
|
+
success: boolean;
|
|
99
|
+
data: string;
|
|
100
|
+
content_type: string;
|
|
101
|
+
transfer_id: string;
|
|
102
|
+
proof_hash: string;
|
|
103
|
+
sender_proof: string;
|
|
104
|
+
}
|
|
105
|
+
interface WebhookChannelCreateRequest {
|
|
106
|
+
/** Human-readable label */
|
|
107
|
+
label?: string;
|
|
108
|
+
/** Channel TTL (e.g., "24h", "7d", "30d") */
|
|
109
|
+
ttl?: string;
|
|
110
|
+
/** Max number of events before channel closes */
|
|
111
|
+
maxEvents?: number;
|
|
112
|
+
/** Burn events after read */
|
|
113
|
+
burnAfterRead?: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface WebhookChannelCreateResponse {
|
|
116
|
+
success: boolean;
|
|
117
|
+
channel_id: string;
|
|
118
|
+
/** The token to use in the webhook URL */
|
|
119
|
+
channel_token: string;
|
|
120
|
+
/** The secret for client-side decryption */
|
|
121
|
+
secret: string;
|
|
122
|
+
/** Full ingest URL: POST to this from your system */
|
|
123
|
+
ingest_url: string;
|
|
124
|
+
expires_at: string;
|
|
125
|
+
}
|
|
126
|
+
interface WebhookEvent {
|
|
127
|
+
id: string;
|
|
128
|
+
encrypted_blob: string;
|
|
129
|
+
iv: string;
|
|
130
|
+
source_ip_hash: string;
|
|
131
|
+
http_method: string;
|
|
132
|
+
content_type: string;
|
|
133
|
+
created_at: string;
|
|
134
|
+
}
|
|
135
|
+
interface WebhookEventsResponse {
|
|
136
|
+
success: boolean;
|
|
137
|
+
events: WebhookEvent[];
|
|
138
|
+
remaining: number;
|
|
139
|
+
}
|
|
140
|
+
interface DeliverRequest {
|
|
141
|
+
/** Content to deliver */
|
|
142
|
+
content: string;
|
|
143
|
+
/** Recipient identifier (optional) */
|
|
144
|
+
to?: string;
|
|
145
|
+
/** TTL (e.g., "5m", "1h", "24h") */
|
|
146
|
+
ttl?: string;
|
|
147
|
+
/** Self-destruct after read */
|
|
148
|
+
burn?: boolean;
|
|
149
|
+
/** Max number of views */
|
|
150
|
+
maxViews?: number;
|
|
151
|
+
}
|
|
152
|
+
interface DeliverResponse {
|
|
153
|
+
success: boolean;
|
|
154
|
+
delivery_id: string;
|
|
155
|
+
/** URL for recipient to open */
|
|
156
|
+
delivery_url: string;
|
|
157
|
+
/** Short code for SMS/voice */
|
|
158
|
+
code?: string;
|
|
159
|
+
expires_at: string;
|
|
160
|
+
proof_hash: string;
|
|
161
|
+
}
|
|
162
|
+
interface EvidenceQuery {
|
|
163
|
+
/** Start date (ISO 8601) */
|
|
164
|
+
from?: string;
|
|
165
|
+
/** End date (ISO 8601) */
|
|
166
|
+
to?: string;
|
|
167
|
+
/** Action type filter */
|
|
168
|
+
action?: string;
|
|
169
|
+
/** Field name filter */
|
|
170
|
+
field?: string;
|
|
171
|
+
/** Max results (default: 100) */
|
|
172
|
+
limit?: number;
|
|
173
|
+
}
|
|
174
|
+
interface EvidenceEntry {
|
|
175
|
+
id: string;
|
|
176
|
+
action: string;
|
|
177
|
+
field_name: string;
|
|
178
|
+
record_type: string;
|
|
179
|
+
proof_hash: string;
|
|
180
|
+
created_at: string;
|
|
181
|
+
}
|
|
182
|
+
interface EvidenceResponse {
|
|
183
|
+
success: boolean;
|
|
184
|
+
entries: EvidenceEntry[];
|
|
185
|
+
total: number;
|
|
186
|
+
}
|
|
187
|
+
interface VaultCreateRequest {
|
|
188
|
+
/** Label for the vault entry */
|
|
189
|
+
label: string;
|
|
190
|
+
/** Pre-encrypted blob (client-side encryption) */
|
|
191
|
+
encrypted_blob: string;
|
|
192
|
+
/** IV used for encryption */
|
|
193
|
+
iv: string;
|
|
194
|
+
/** Metadata (never encrypted by server) */
|
|
195
|
+
metadata?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
interface VaultCreateResponse {
|
|
198
|
+
success: boolean;
|
|
199
|
+
vault_id: string;
|
|
200
|
+
}
|
|
201
|
+
interface VaultReadResponse {
|
|
202
|
+
success: boolean;
|
|
203
|
+
vault_id: string;
|
|
204
|
+
encrypted_blob: string;
|
|
205
|
+
iv: string;
|
|
206
|
+
label: string;
|
|
207
|
+
metadata?: Record<string, unknown>;
|
|
208
|
+
created_at: string;
|
|
209
|
+
}
|
|
210
|
+
interface PluginConfig {
|
|
211
|
+
/** NoData API key */
|
|
212
|
+
apiKey: string;
|
|
213
|
+
/** Base URL */
|
|
214
|
+
baseUrl?: string;
|
|
215
|
+
/** Fields to auto-encrypt in responses */
|
|
216
|
+
encryptFields?: string[];
|
|
217
|
+
/** Fields to auto-decrypt in requests */
|
|
218
|
+
decryptFields?: string[];
|
|
219
|
+
/** Header that must be present for decryption (security gate) */
|
|
220
|
+
decryptHeader?: string;
|
|
221
|
+
/** Paths to skip (glob patterns) */
|
|
222
|
+
skipPaths?: string[];
|
|
223
|
+
/** Audit context */
|
|
224
|
+
context?: string;
|
|
225
|
+
}
|
|
226
|
+
declare class NoDataError extends Error {
|
|
227
|
+
status: number;
|
|
228
|
+
code?: string | undefined;
|
|
229
|
+
retryAfter?: number | undefined;
|
|
230
|
+
constructor(message: string, status: number, code?: string | undefined, retryAfter?: number | undefined);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { type BatchResult as B, type ChannelCreateRequest as C, type DeliverRequest as D, type EvidenceQuery as E, type NoDataConfig as N, type PluginConfig as P, type VaultCreateRequest as V, type WebhookChannelCreateRequest as W, type ChannelCreateResponse as a, type ChannelSendRequest as b, type ChannelSendResponse as c, type ChannelReceiveRequest as d, type ChannelReceiveResponse as e, type WebhookChannelCreateResponse as f, type WebhookEventsResponse as g, type DeliverResponse as h, type EvidenceResponse as i, type VaultCreateResponse as j, type VaultReadResponse as k, type EncryptRequest as l, type EncryptResponse as m, type DecryptRequest as n, type DecryptResponse as o, type EvidenceEntry as p, NoDataError as q, type WebhookEvent as r };
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nodatachat/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "NoData M2M SDK — Blind relay encryption, secure channels, and zero-knowledge delivery for machine-to-machine communication.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./express": {
|
|
15
|
+
"types": "./dist/plugins/express.d.ts",
|
|
16
|
+
"import": "./dist/plugins/express.mjs",
|
|
17
|
+
"require": "./dist/plugins/express.js"
|
|
18
|
+
},
|
|
19
|
+
"./fastify": {
|
|
20
|
+
"types": "./dist/plugins/fastify.d.ts",
|
|
21
|
+
"import": "./dist/plugins/fastify.mjs",
|
|
22
|
+
"require": "./dist/plugins/fastify.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": ["dist", "README.md"],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup src/index.ts src/plugins/express.ts src/plugins/fastify.ts --format esm,cjs --dts",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"prepublishOnly": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"nodata",
|
|
34
|
+
"encryption",
|
|
35
|
+
"m2m",
|
|
36
|
+
"machine-to-machine",
|
|
37
|
+
"blind-relay",
|
|
38
|
+
"zero-knowledge",
|
|
39
|
+
"pii",
|
|
40
|
+
"soc",
|
|
41
|
+
"compliance",
|
|
42
|
+
"field-level-encryption",
|
|
43
|
+
"sdk"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/nodatachat/sdk"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://www.nodatachat.com/developers",
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"express": ">=4.0.0",
|
|
53
|
+
"fastify": ">=4.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"express": { "optional": true },
|
|
57
|
+
"fastify": { "optional": true }
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"tsup": "^8.0.0",
|
|
61
|
+
"typescript": "^5.7.0",
|
|
62
|
+
"vitest": "^3.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|