@zincapp/znvault-cli 4.24.2 → 4.24.4

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 (53) hide show
  1. package/dist/commands/dynamic-secrets/index.d.ts.map +1 -1
  2. package/dist/commands/dynamic-secrets/index.js +71 -2
  3. package/dist/commands/dynamic-secrets/index.js.map +1 -1
  4. package/dist/commands/dynamic-secrets/permit.d.ts +6 -0
  5. package/dist/commands/dynamic-secrets/permit.d.ts.map +1 -0
  6. package/dist/commands/dynamic-secrets/permit.js +139 -0
  7. package/dist/commands/dynamic-secrets/permit.js.map +1 -0
  8. package/dist/commands/dynamic-secrets/recovery-fence.d.ts +5 -0
  9. package/dist/commands/dynamic-secrets/recovery-fence.d.ts.map +1 -0
  10. package/dist/commands/dynamic-secrets/recovery-fence.js +84 -0
  11. package/dist/commands/dynamic-secrets/recovery-fence.js.map +1 -0
  12. package/dist/commands/dynamic-secrets/recovery-parse.d.ts +4 -0
  13. package/dist/commands/dynamic-secrets/recovery-parse.d.ts.map +1 -0
  14. package/dist/commands/dynamic-secrets/recovery-parse.js +22 -0
  15. package/dist/commands/dynamic-secrets/recovery-parse.js.map +1 -0
  16. package/dist/commands/dynamic-secrets/recovery-types.d.ts +127 -0
  17. package/dist/commands/dynamic-secrets/recovery-types.d.ts.map +1 -0
  18. package/dist/commands/dynamic-secrets/recovery-types.js +3 -0
  19. package/dist/commands/dynamic-secrets/recovery-types.js.map +1 -0
  20. package/dist/commands/dynamic-secrets/role.d.ts +2 -5
  21. package/dist/commands/dynamic-secrets/role.d.ts.map +1 -1
  22. package/dist/commands/dynamic-secrets/role.js +10 -2
  23. package/dist/commands/dynamic-secrets/role.js.map +1 -1
  24. package/dist/commands/dynamic-secrets/types.d.ts +10 -0
  25. package/dist/commands/dynamic-secrets/types.d.ts.map +1 -1
  26. package/dist/commands/mysql/index.d.ts +2 -0
  27. package/dist/commands/mysql/index.d.ts.map +1 -1
  28. package/dist/commands/mysql/index.js +70 -2
  29. package/dist/commands/mysql/index.js.map +1 -1
  30. package/dist/commands/mysql/mycnf.d.ts +2 -2
  31. package/dist/commands/mysql/mycnf.d.ts.map +1 -1
  32. package/dist/commands/mysql/mycnf.js +1 -1
  33. package/dist/commands/mysql/mycnf.js.map +1 -1
  34. package/dist/commands/mysql/permit-broker.d.ts +35 -0
  35. package/dist/commands/mysql/permit-broker.d.ts.map +1 -0
  36. package/dist/commands/mysql/permit-broker.js +365 -0
  37. package/dist/commands/mysql/permit-broker.js.map +1 -0
  38. package/dist/commands/mysql/recovery-hpke.d.ts +32 -0
  39. package/dist/commands/mysql/recovery-hpke.d.ts.map +1 -0
  40. package/dist/commands/mysql/recovery-hpke.js +311 -0
  41. package/dist/commands/mysql/recovery-hpke.js.map +1 -0
  42. package/dist/commands/mysql/run.d.ts +59 -19
  43. package/dist/commands/mysql/run.d.ts.map +1 -1
  44. package/dist/commands/mysql/run.js +399 -46
  45. package/dist/commands/mysql/run.js.map +1 -1
  46. package/dist/commands/mysql/types.d.ts +7 -0
  47. package/dist/commands/mysql/types.d.ts.map +1 -1
  48. package/dist/lib/client/http.d.ts.map +1 -1
  49. package/dist/lib/client/http.js +18 -0
  50. package/dist/lib/client/http.js.map +1 -1
  51. package/dist/lib/client/types.d.ts +6 -0
  52. package/dist/lib/client/types.d.ts.map +1 -1
  53. package/package.json +6 -2
@@ -0,0 +1,311 @@
1
+ /**
2
+ * Consumer-side HPKE for Dynamic Secrets Recovery Fence v1.
3
+ *
4
+ * The X25519 private key is a process-local CryptoKey. It is never serialized,
5
+ * written to disk, printed, placed in argv, or copied into the environment.
6
+ */
7
+ import { createHash, timingSafeEqual } from 'node:crypto';
8
+ import { TextDecoder } from 'node:util';
9
+ import { Chacha20Poly1305 } from '@hpke/chacha20poly1305';
10
+ import { CipherSuite, HkdfSha256 } from '@hpke/core';
11
+ import { DhkemX25519HkdfSha256 } from '@hpke/dhkem-x25519';
12
+ const DELIVERY_FORMAT = 'hpke-v1';
13
+ const SUITE_NAME = 'X25519-HKDF-SHA256-ChaCha20Poly1305';
14
+ const INFO = 'znvault.dynsec.recovery-credential.hpke-v1';
15
+ const AAD_SCHEMA = 'znvault.dynsec.recovery-credential-aad.v1';
16
+ const CREDENTIAL_SCHEMA = 'znvault.dynsec.recovery-credential.v1';
17
+ const SHA256 = /^sha256:[0-9a-f]{64}$/;
18
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
19
+ const BASE64URL = /^[A-Za-z0-9_-]+$/;
20
+ const IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/;
21
+ const utf8 = new TextDecoder('utf-8', { fatal: true });
22
+ function suite() {
23
+ return new CipherSuite({
24
+ kem: new DhkemX25519HkdfSha256(),
25
+ kdf: new HkdfSha256(),
26
+ aead: new Chacha20Poly1305(),
27
+ });
28
+ }
29
+ function isRecord(value) {
30
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
31
+ }
32
+ function hasExactKeys(value, expected) {
33
+ const actual = Object.keys(value).sort();
34
+ const wanted = [...expected].sort();
35
+ return actual.length === wanted.length && actual.every((key, index) => key === wanted[index]);
36
+ }
37
+ function canonicalize(value) {
38
+ if (Array.isArray(value))
39
+ return value.map(canonicalize);
40
+ if (isRecord(value)) {
41
+ const result = {};
42
+ for (const key of Object.keys(value).sort())
43
+ result[key] = canonicalize(value[key]);
44
+ return result;
45
+ }
46
+ return value;
47
+ }
48
+ export function canonicalJsonBytes(value) {
49
+ return Buffer.from(JSON.stringify(canonicalize(value)), 'utf8');
50
+ }
51
+ function sha256KeyId(value) {
52
+ return `sha256:${createHash('sha256').update(value).digest('hex')}`;
53
+ }
54
+ function canonicalBase64Url(value, expectedBytes, maxBytes) {
55
+ if (typeof value !== 'string' || value.length === 0 || !BASE64URL.test(value)) {
56
+ throw new Error('Recovery HPKE response contains invalid base64url');
57
+ }
58
+ const decoded = Buffer.from(value, 'base64url');
59
+ if (decoded.toString('base64url') !== value
60
+ || (expectedBytes !== undefined && decoded.length !== expectedBytes)
61
+ || (maxBytes !== undefined && decoded.length > maxBytes)) {
62
+ decoded.fill(0);
63
+ throw new Error('Recovery HPKE response contains non-canonical base64url');
64
+ }
65
+ return decoded;
66
+ }
67
+ function canonicalTimestamp(value) {
68
+ if (typeof value !== 'string')
69
+ throw new Error('Recovery HPKE response contains an invalid timestamp');
70
+ const date = new Date(value);
71
+ if (!Number.isFinite(date.getTime()) || date.toISOString() !== value) {
72
+ throw new Error('Recovery HPKE response contains a non-canonical timestamp');
73
+ }
74
+ return value;
75
+ }
76
+ function requireIdentifier(value) {
77
+ if (typeof value !== 'string' || !IDENTIFIER.test(value)) {
78
+ throw new Error('Recovery HPKE response contains an invalid identifier');
79
+ }
80
+ return value;
81
+ }
82
+ function requirePositiveInteger(value) {
83
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0) {
84
+ throw new Error('Recovery HPKE response contains an invalid epoch or revision');
85
+ }
86
+ return value;
87
+ }
88
+ function requireDigest(value, prefixed) {
89
+ if (typeof value !== 'string' || !(prefixed ? SHA256 : SHA256_HEX).test(value)) {
90
+ throw new Error('Recovery HPKE response contains an invalid SHA-256 identity');
91
+ }
92
+ return value;
93
+ }
94
+ function requireOverlay(value) {
95
+ if (value !== 'NONE' && value !== 'MYSQL_SCHEMA_LOCK_TABLES') {
96
+ throw new Error('Recovery HPKE response contains an invalid privilege overlay');
97
+ }
98
+ return value;
99
+ }
100
+ function parseAad(raw) {
101
+ if (raw.length === 0 || raw.length > 16_384)
102
+ throw new Error('Recovery HPKE AAD is too large');
103
+ let candidate;
104
+ try {
105
+ candidate = JSON.parse(utf8.decode(raw));
106
+ }
107
+ catch {
108
+ throw new Error('Recovery HPKE AAD is not valid UTF-8 JSON');
109
+ }
110
+ const keys = [
111
+ 'schema', 'version', 'deliveryFormat', 'suite', 'tenantId', 'roleId',
112
+ 'fenceId', 'fenceEpoch', 'permitId', 'requestId', 'leaseId',
113
+ 'consumerApiKeyId', 'roleRevision', 'roleConfigSha256', 'grantPlanSha256',
114
+ 'recipientKeyId', 'credentialExpiresAt', 'privilegeOverlay',
115
+ ];
116
+ if (!isRecord(candidate)
117
+ || !hasExactKeys(candidate, keys)
118
+ || candidate.schema !== AAD_SCHEMA
119
+ || candidate.version !== 1
120
+ || candidate.deliveryFormat !== DELIVERY_FORMAT
121
+ || candidate.suite !== SUITE_NAME) {
122
+ throw new Error('Recovery HPKE AAD has an invalid contract shape');
123
+ }
124
+ if (!canonicalJsonBytes(candidate).equals(raw)) {
125
+ throw new Error('Recovery HPKE AAD is not canonical JSON');
126
+ }
127
+ return {
128
+ schema: AAD_SCHEMA,
129
+ version: 1,
130
+ deliveryFormat: DELIVERY_FORMAT,
131
+ suite: SUITE_NAME,
132
+ tenantId: requireIdentifier(candidate.tenantId),
133
+ roleId: requireIdentifier(candidate.roleId),
134
+ fenceId: requireIdentifier(candidate.fenceId),
135
+ fenceEpoch: requirePositiveInteger(candidate.fenceEpoch),
136
+ permitId: requireIdentifier(candidate.permitId),
137
+ requestId: requireIdentifier(candidate.requestId),
138
+ leaseId: requireIdentifier(candidate.leaseId),
139
+ consumerApiKeyId: requireIdentifier(candidate.consumerApiKeyId),
140
+ roleRevision: requirePositiveInteger(candidate.roleRevision),
141
+ roleConfigSha256: requireDigest(candidate.roleConfigSha256, false),
142
+ grantPlanSha256: requireDigest(candidate.grantPlanSha256, false),
143
+ recipientKeyId: requireDigest(candidate.recipientKeyId, true),
144
+ credentialExpiresAt: canonicalTimestamp(candidate.credentialExpiresAt),
145
+ privilegeOverlay: requireOverlay(candidate.privilegeOverlay),
146
+ };
147
+ }
148
+ function assertEnvelope(value) {
149
+ const candidate = value;
150
+ if (!isRecord(candidate)
151
+ || !hasExactKeys(candidate, ['version', 'suite', 'enc', 'ciphertext', 'aadSha256'])
152
+ || candidate.version !== DELIVERY_FORMAT
153
+ || candidate.suite !== SUITE_NAME) {
154
+ throw new Error('Recovery HPKE envelope has an invalid contract shape');
155
+ }
156
+ requireDigest(candidate.aadSha256, true);
157
+ }
158
+ function assertBoundAad(aad, operation, recipient) {
159
+ const exactBindings = [
160
+ [aad.tenantId, operation.tenantId, 'tenant'],
161
+ [aad.roleId, operation.roleId, 'role'],
162
+ [aad.fenceId, operation.fenceId, 'fence'],
163
+ [aad.permitId, operation.permitId, 'permit'],
164
+ [aad.requestId, operation.requestId, 'request'],
165
+ [aad.leaseId, operation.leaseId, 'lease'],
166
+ [aad.roleConfigSha256, operation.roleConfigSha256, 'role digest'],
167
+ [aad.grantPlanSha256, operation.grantPlanSha256, 'grant-plan digest'],
168
+ [aad.recipientKeyId, recipient.recipientKeyId, 'recipient'],
169
+ [aad.credentialExpiresAt, operation.credentialExpiresAt, 'expiry'],
170
+ [aad.privilegeOverlay, operation.privilegeOverlay, 'privilege overlay'],
171
+ [aad.consumerApiKeyId, operation.consumerApiKeyId, 'consumer API key'],
172
+ ];
173
+ for (const [actual, expected, name] of exactBindings) {
174
+ if (actual !== expected)
175
+ throw new Error(`Recovery HPKE ${name} binding does not match the operation`);
176
+ }
177
+ if (aad.fenceEpoch !== operation.fenceEpoch || aad.roleRevision !== operation.roleRevision) {
178
+ throw new Error('Recovery HPKE epoch or role revision binding does not match the operation');
179
+ }
180
+ }
181
+ function safeOptionValue(value, field, maxLength) {
182
+ if (typeof value !== 'string'
183
+ || value.length === 0
184
+ || value.length > maxLength
185
+ || /[\0\r\n]/.test(value)) {
186
+ throw new Error(`Decrypted recovery credential has an invalid ${field}`);
187
+ }
188
+ return value;
189
+ }
190
+ function parseCredential(raw, expectedExpiresAt) {
191
+ let candidate;
192
+ try {
193
+ candidate = JSON.parse(utf8.decode(raw));
194
+ }
195
+ catch {
196
+ throw new Error('Decrypted recovery credential is not valid UTF-8 JSON');
197
+ }
198
+ const keys = ['schema', 'version', 'username', 'password', 'host', 'port', 'database', 'expiresAt'];
199
+ if (!isRecord(candidate)
200
+ || !hasExactKeys(candidate, keys)
201
+ || candidate.schema !== CREDENTIAL_SCHEMA
202
+ || candidate.version !== 1
203
+ || !canonicalJsonBytes(candidate).equals(raw)
204
+ || !Number.isSafeInteger(candidate.port)
205
+ || candidate.port < 1
206
+ || candidate.port > 65_535) {
207
+ throw new Error('Decrypted recovery credential has an invalid contract shape');
208
+ }
209
+ const expiresAt = canonicalTimestamp(candidate.expiresAt);
210
+ if (expiresAt !== expectedExpiresAt) {
211
+ throw new Error('Decrypted recovery credential expiry does not match authenticated metadata');
212
+ }
213
+ return {
214
+ schema: CREDENTIAL_SCHEMA,
215
+ version: 1,
216
+ username: safeOptionValue(candidate.username, 'username', 255),
217
+ password: safeOptionValue(candidate.password, 'password', 4_096),
218
+ host: safeOptionValue(candidate.host, 'host', 255),
219
+ port: candidate.port,
220
+ database: safeOptionValue(candidate.database, 'database', 255),
221
+ expiresAt,
222
+ };
223
+ }
224
+ export async function generateEphemeralRecoveryRecipient() {
225
+ const hpke = suite();
226
+ // The packages expose the KEM methods at runtime, while their nested type is
227
+ // intentionally abstract. Narrow the two methods this consumer needs.
228
+ const kem = hpke.kem;
229
+ const keyPair = await kem.generateKeyPair();
230
+ const rawPublicKey = Buffer.from(await kem.serializePublicKey(keyPair.publicKey));
231
+ try {
232
+ if (rawPublicKey.length !== 32 || rawPublicKey.every(byte => byte === 0)) {
233
+ throw new Error('Failed to generate a valid ephemeral X25519 recipient');
234
+ }
235
+ return Object.freeze({
236
+ recipientPublicKey: rawPublicKey.toString('base64url'),
237
+ recipientKeyId: sha256KeyId(rawPublicKey),
238
+ privateKey: keyPair.privateKey,
239
+ });
240
+ }
241
+ finally {
242
+ rawPublicKey.fill(0);
243
+ }
244
+ }
245
+ export async function openRecoveryCredential(input) {
246
+ const { delivery, operation, recipient } = input;
247
+ const wireDelivery = delivery;
248
+ if (!isRecord(wireDelivery)
249
+ || wireDelivery.deliveryFormat !== DELIVERY_FORMAT
250
+ || wireDelivery.permitId !== operation.permitId
251
+ || wireDelivery.requestId !== operation.requestId
252
+ || (wireDelivery.state !== 'CONSUMED' && wireDelivery.state !== 'DELIVERED')) {
253
+ throw new Error('Recovery credential delivery does not match the requested operation');
254
+ }
255
+ assertEnvelope(delivery.envelope);
256
+ const aad = canonicalBase64Url(delivery.aad, undefined, 16_384);
257
+ const enc = canonicalBase64Url(delivery.envelope.enc, 32);
258
+ const ciphertext = canonicalBase64Url(delivery.envelope.ciphertext, undefined, 16_384);
259
+ let plaintext;
260
+ try {
261
+ if (ciphertext.length <= 16)
262
+ throw new Error('Recovery HPKE ciphertext is too short');
263
+ const expectedAadDigest = Buffer.from(delivery.envelope.aadSha256.slice('sha256:'.length), 'hex');
264
+ const actualAadDigest = createHash('sha256').update(aad).digest();
265
+ try {
266
+ if (!timingSafeEqual(expectedAadDigest, actualAadDigest)) {
267
+ throw new Error('Recovery HPKE envelope does not authenticate the supplied AAD');
268
+ }
269
+ }
270
+ finally {
271
+ expectedAadDigest.fill(0);
272
+ actualAadDigest.fill(0);
273
+ }
274
+ const providedEnvelopeSha256 = requireDigest(delivery.envelopeSha256, true);
275
+ const expectedEnvelopeDigest = Buffer.from(providedEnvelopeSha256.slice('sha256:'.length), 'hex');
276
+ const actualEnvelopeDigest = createHash('sha256')
277
+ .update(canonicalJsonBytes(delivery.envelope))
278
+ .digest();
279
+ try {
280
+ if (!timingSafeEqual(expectedEnvelopeDigest, actualEnvelopeDigest)) {
281
+ throw new Error('Recovery HPKE envelope digest does not match the persisted envelope');
282
+ }
283
+ }
284
+ finally {
285
+ expectedEnvelopeDigest.fill(0);
286
+ actualEnvelopeDigest.fill(0);
287
+ }
288
+ const parsedAad = parseAad(aad);
289
+ assertBoundAad(parsedAad, operation, recipient);
290
+ let opened;
291
+ try {
292
+ opened = await suite().open({
293
+ recipientKey: recipient.privateKey,
294
+ enc,
295
+ info: Buffer.from(INFO, 'utf8'),
296
+ }, ciphertext, aad);
297
+ }
298
+ catch {
299
+ throw new Error('Recovery HPKE credential authentication failed');
300
+ }
301
+ plaintext = Buffer.from(opened);
302
+ return parseCredential(plaintext, parsedAad.credentialExpiresAt);
303
+ }
304
+ finally {
305
+ aad.fill(0);
306
+ enc.fill(0);
307
+ ciphertext.fill(0);
308
+ plaintext?.fill(0);
309
+ }
310
+ }
311
+ //# sourceMappingURL=recovery-hpke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery-hpke.js","sourceRoot":"","sources":["../../../src/commands/mysql/recovery-hpke.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAQzD,MAAM,eAAe,GAAG,SAAkB,CAAC;AAC3C,MAAM,UAAU,GAAG,qCAA8C,CAAC;AAClE,MAAM,IAAI,GAAG,4CAA4C,CAAC;AAC1D,MAAM,UAAU,GAAG,2CAA2C,CAAC;AAC/D,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAClE,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACrC,MAAM,UAAU,GAAG,qCAAqC,CAAC;AACzD,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;AAkDrD,SAAS,KAAK;IACZ,OAAO,IAAI,WAAW,CAAC;QACrB,GAAG,EAAE,IAAI,qBAAqB,EAAE;QAChC,GAAG,EAAE,IAAI,UAAU,EAAE;QACrB,IAAI,EAAE,IAAI,gBAAgB,EAAE;KAC7B,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAA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AAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;aAChC,EACD,UAAU,EACV,GAAG,CACJ,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QACD,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACnE,CAAC;YAAS,CAAC;QACT,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -9,18 +9,16 @@
9
9
  */
10
10
  export declare function assertMysqlOnPath(): string;
11
11
  /**
12
- * Reject any passthrough token that is (or starts with `=`-form of) a forbidden
13
- * connection/credential/defaults override flag.
12
+ * Accept only the fixed allowlist of argument-free presentation flags.
13
+ * Forbidden-option recognition below exists for actionable diagnostics; the
14
+ * final generic rejection is the security boundary for unknown future flags.
14
15
  *
15
16
  * Recognised forms for a forbidden flag `--host`:
16
17
  * - exact: `--host` (its value is the next token)
17
18
  * - inline: `--host=value`
18
19
  * - short: `-h` (value is next token) / `-P`, `-p`
19
20
  *
20
- * Tokens that merely START with a forbidden name but are a different flag
21
- * (e.g. `--hostgroup`, `--port-something`) are NOT rejected.
22
- *
23
- * @throws Error naming the offending flag and citing F2, on the first match.
21
+ * @throws Error naming the first non-allowlisted token.
24
22
  */
25
23
  export declare function assertPassthroughAllowed(passthrough: readonly string[]): void;
26
24
  /**
@@ -30,15 +28,47 @@ export declare function assertPassthroughAllowed(passthrough: readonly string[])
30
28
  */
31
29
  export interface BuildMysqlInvocationOpts {
32
30
  /**
33
- * Value for `--defaults-extra-file`. This is the `/dev/fd/<fd>` path returned
31
+ * Value for `--defaults-file`. This is the `/dev/fd/<fd>` path returned
34
32
  * by createMyCnf (B2) — mysql re-opens the inherited fd through it.
35
33
  */
36
34
  fdPath: string;
37
35
  /** Optional default schema to select (positional arg — spec F8). */
38
36
  database?: string;
39
- /** Extra arguments appended verbatim to the mysql argv. */
37
+ /** Allowlisted, argument-free mysql presentation flags. */
40
38
  passthrough?: string[];
39
+ /**
40
+ * Capability discovered from the selected client. Oracle MySQL needs
41
+ * --no-login-paths; MariaDB has no login-path feature and rejects the flag.
42
+ */
43
+ supportsNoLoginPaths?: boolean;
44
+ /** Force non-interactive client-command isolation for piped SQL. */
45
+ binaryMode?: boolean;
41
46
  }
47
+ /**
48
+ * Validate the optional positional schema before it reaches mysql argv.
49
+ *
50
+ * MySQL identifiers can be broader when quoted inside SQL, but the CLI schema
51
+ * selector is deliberately a conservative ASCII contract. This prevents a
52
+ * value beginning with `-` from being interpreted as a client option and keeps
53
+ * control characters or shell-like path material out of process arguments.
54
+ */
55
+ export declare function assertSafeMysqlDatabase(database: string | undefined): void;
56
+ export interface MysqlClientCapabilities {
57
+ binary: string;
58
+ family: 'mysql' | 'mariadb';
59
+ supportsNoLoginPaths: boolean;
60
+ supportsBinaryMode: boolean;
61
+ }
62
+ export declare function assertMysqlExecCapabilities(capabilities: MysqlClientCapabilities): void;
63
+ /**
64
+ * Probe option-file isolation before a lease/permit is consumed.
65
+ *
66
+ * Oracle MySQL clients expose --no-login-paths and require it to exclude
67
+ * .mylogin.cnf. MariaDB clients do not implement login paths and reject that
68
+ * flag, so their exclusive --defaults-file is sufficient. Unknown clients
69
+ * without the Oracle flag fail closed.
70
+ */
71
+ export declare function inspectMysqlClient(binary?: string): MysqlClientCapabilities;
42
72
  /**
43
73
  * Build the mysql argv and child environment.
44
74
  *
@@ -47,14 +77,17 @@ export interface BuildMysqlInvocationOpts {
47
77
  * without spawning real mysql.
48
78
  *
49
79
  * Security invariants:
50
- * - `--defaults-extra-file=<fdPath>` is args[0].
80
+ * - `--defaults-file=<fdPath>` is args[0]. Oracle MySQL then receives
81
+ * `--no-login-paths`; MariaDB omits the unsupported flag after probing.
82
+ * - Exec invocations force `--binary-mode` before the positional schema.
51
83
  * - No --user / -u / --password / -p / MYSQL_PWD in args or env.
52
84
  * - No --host / --port / -h / -P flags (connection coords from cnf).
53
- * - Forbidden override flags in `passthrough` are rejected (spec F2).
85
+ * - Only fixed, argument-free passthrough flags are accepted (spec F2).
86
+ * - The child environment is a non-secret allowlist; Vault credentials and
87
+ * ambient MySQL selectors are never inherited.
54
88
  * - MYSQL_HISTFILE=/dev/null overrides any pre-existing value.
55
89
  *
56
- * @throws If `passthrough` contains a forbidden connection/credential/defaults
57
- * override flag (see assertPassthroughAllowed).
90
+ * @throws If `passthrough` contains a token outside the fixed safe allowlist.
58
91
  */
59
92
  export declare function buildMysqlInvocation(opts: BuildMysqlInvocationOpts): {
60
93
  args: string[];
@@ -68,7 +101,7 @@ type StdioEntry = 'pipe' | 'inherit' | 'ignore' | number;
68
101
  /**
69
102
  * Build the `stdio` array for spawning mysql so that the cnf fd is inherited by
70
103
  * the child at the SAME numeric index `fd`. This is what makes
71
- * `--defaults-extra-file=/dev/fd/<fd>` resolve correctly in the child: the
104
+ * `--defaults-file=/dev/fd/<fd>` resolve correctly in the child: the
72
105
  * child must have an fd open at exactly `fd`.
73
106
  *
74
107
  * Layout:
@@ -96,7 +129,7 @@ export declare function buildChildStdio(fd: number, stdin0: 'pipe' | 'inherit'):
96
129
  export interface RunMysqlOpts {
97
130
  /**
98
131
  * The `/dev/fd/<fd>` path returned by createMyCnf — passed to mysql as
99
- * --defaults-extra-file. This module never re-opens it; mysql reads the
132
+ * --defaults-file. This module never re-opens it; mysql reads the
100
133
  * inherited fd through it.
101
134
  */
102
135
  fdPath: string;
@@ -120,6 +153,12 @@ export interface RunMysqlOpts {
120
153
  * Precedence: files → sql → parent stdin (spec F-input).
121
154
  */
122
155
  sql?: string;
156
+ /**
157
+ * (exec mode) Exact already-validated bytes to feed as stdin. Recovery
158
+ * permits use this so the file is validated before the one-shot consume and
159
+ * cannot change between validation and mysql execution.
160
+ */
161
+ input?: Buffer;
123
162
  /** Extra arguments appended verbatim to the mysql argv. */
124
163
  passthrough?: string[];
125
164
  }
@@ -128,16 +167,17 @@ export interface RunMysqlOpts {
128
167
  *
129
168
  * - Resolves with the child's numeric exit code (caller/CI relies on non-zero).
130
169
  * - The cnf fd (`opts.fd`) is inherited by the child at the SAME number so
131
- * `--defaults-extra-file=/dev/fd/<fd>` resolves in the child (spec F1). The
170
+ * `--defaults-file=/dev/fd/<fd>` resolves in the child (spec F1). The
132
171
  * directory entry was already unlinked in createMyCnf — there is NOTHING to
133
172
  * unlink here, and NO post-spawn unlink race.
134
173
  * - 'connect' mode: stdin/stdout/stderr are inherited (interactive terminal);
135
174
  * the cnf fd is additionally inherited at index `fd`.
136
175
  * - 'exec' mode: stdin (index 0) is wired as:
137
- * 1. files (concatenated, in order) → stdin pipe
138
- * 2. sql (string) → stdin pipe
139
- * 3. parent stdin (if not a TTY) → piped through (inherit)
140
- * 4. parent stdin is a TTY and neither files nor sql provided → Error
176
+ * 1. input (exact Buffer) → stdin pipe
177
+ * 2. files (concatenated, in order) → stdin pipe
178
+ * 3. sql (string) → stdin pipe
179
+ * 4. parent stdin (if not a TTY) piped through (inherit)
180
+ * 5. parent stdin is a TTY and no source was provided → Error
141
181
  * stdout/stderr are inherited; the cnf fd is inherited at index `fd`.
142
182
  *
143
183
  * The parent's own copy of `opts.fd` is intentionally NOT closed here — the
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/mysql/run.ts"],"names":[],"mappings":"AAwCA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAsB1C;AAoCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAa7E;AA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