@squadbase/connectors 0.0.12 → 0.0.13
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.js +22 -9
- package/package.json +1 -3
package/dist/index.js
CHANGED
|
@@ -285,6 +285,19 @@ var parameters3 = {
|
|
|
285
285
|
|
|
286
286
|
// src/connectors/snowflake/tools/execute-query.ts
|
|
287
287
|
import { z } from "zod";
|
|
288
|
+
|
|
289
|
+
// src/connectors/snowflake/utils.ts
|
|
290
|
+
import crypto from "crypto";
|
|
291
|
+
function decryptPrivateKey(pem, passphrase) {
|
|
292
|
+
if (!passphrase) return pem;
|
|
293
|
+
return crypto.createPrivateKey({
|
|
294
|
+
key: pem,
|
|
295
|
+
format: "pem",
|
|
296
|
+
passphrase
|
|
297
|
+
}).export({ type: "pkcs8", format: "pem" });
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/connectors/snowflake/tools/execute-query.ts
|
|
288
301
|
var MAX_ROWS = 500;
|
|
289
302
|
var QUERY_TIMEOUT_MS = 6e4;
|
|
290
303
|
var inputSchema = z.object({
|
|
@@ -334,18 +347,18 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
334
347
|
const role = parameters3.role.getValue(connection);
|
|
335
348
|
const warehouse = parameters3.warehouse.getValue(connection);
|
|
336
349
|
const privateKeyBase64 = parameters3.privateKeyBase64.getValue(connection);
|
|
337
|
-
const
|
|
350
|
+
const privateKeyPem = Buffer.from(privateKeyBase64, "base64").toString(
|
|
338
351
|
"utf-8"
|
|
339
352
|
);
|
|
340
353
|
const privateKeyPass = parameters3.privateKeyPassphrase.tryGetValue(connection);
|
|
354
|
+
const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass ?? void 0);
|
|
341
355
|
const conn = snowflake.createConnection({
|
|
342
356
|
account,
|
|
343
357
|
username: user,
|
|
344
358
|
role,
|
|
345
359
|
warehouse,
|
|
346
360
|
authenticator: "SNOWFLAKE_JWT",
|
|
347
|
-
privateKey
|
|
348
|
-
...privateKeyPass ? { privateKeyPass } : {}
|
|
361
|
+
privateKey
|
|
349
362
|
});
|
|
350
363
|
await new Promise((resolve, reject) => {
|
|
351
364
|
conn.connect((err) => {
|
|
@@ -418,19 +431,19 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
418
431
|
try {
|
|
419
432
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
420
433
|
snowflake.configure({ logLevel: "ERROR" });
|
|
421
|
-
const
|
|
434
|
+
const privateKeyPem = Buffer.from(
|
|
422
435
|
params[parameters3.privateKeyBase64.slug],
|
|
423
436
|
"base64"
|
|
424
437
|
).toString("utf-8");
|
|
425
438
|
const privateKeyPass = params[parameters3.privateKeyPassphrase.slug] || void 0;
|
|
439
|
+
const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass);
|
|
426
440
|
const conn = snowflake.createConnection({
|
|
427
441
|
account: params[parameters3.account.slug],
|
|
428
442
|
username: params[parameters3.user.slug],
|
|
429
443
|
role: params[parameters3.role.slug],
|
|
430
444
|
warehouse: params[parameters3.warehouse.slug],
|
|
431
445
|
authenticator: "SNOWFLAKE_JWT",
|
|
432
|
-
privateKey
|
|
433
|
-
...privateKeyPass ? { privateKeyPass } : {}
|
|
446
|
+
privateKey
|
|
434
447
|
});
|
|
435
448
|
await new Promise((resolve, reject) => {
|
|
436
449
|
conn.connect((err) => {
|
|
@@ -459,19 +472,19 @@ var snowflakeConnector = new ConnectorPlugin({
|
|
|
459
472
|
const resolvedSql = replaceLiteralParams(sql, namedParams);
|
|
460
473
|
const snowflake = (await import("snowflake-sdk")).default;
|
|
461
474
|
snowflake.configure({ logLevel: "ERROR" });
|
|
462
|
-
const
|
|
475
|
+
const privateKeyPem = Buffer.from(
|
|
463
476
|
params[parameters3.privateKeyBase64.slug],
|
|
464
477
|
"base64"
|
|
465
478
|
).toString("utf-8");
|
|
466
479
|
const privateKeyPass = params[parameters3.privateKeyPassphrase.slug] || void 0;
|
|
480
|
+
const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass);
|
|
467
481
|
const conn = snowflake.createConnection({
|
|
468
482
|
account: params[parameters3.account.slug],
|
|
469
483
|
username: params[parameters3.user.slug],
|
|
470
484
|
role: params[parameters3.role.slug],
|
|
471
485
|
warehouse: params[parameters3.warehouse.slug],
|
|
472
486
|
authenticator: "SNOWFLAKE_JWT",
|
|
473
|
-
privateKey
|
|
474
|
-
...privateKeyPass ? { privateKeyPass } : {}
|
|
487
|
+
privateKey
|
|
475
488
|
});
|
|
476
489
|
await new Promise((resolve, reject) => {
|
|
477
490
|
conn.connect((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squadbase/connectors",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Squadbase Connectors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,11 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsup",
|
|
30
|
-
"add-connector": "tsx scripts/add-connector.ts",
|
|
31
30
|
"sync:dev1": "API_BASE_URL=https://dev1-api.squadbase.dev/v0 dotenv tsx scripts/sync-connectors.ts",
|
|
32
31
|
"sync:dev2": "API_BASE_URL=https://dev2-api.squadbase.dev/v0 dotenv tsx scripts/sync-connectors.ts",
|
|
33
32
|
"sync:prod": "API_BASE_URL=https://api.squadbase.dev/v0 dotenv tsx scripts/sync-connectors.ts",
|
|
34
|
-
"prepare-test-datasource": "tsx scripts/prepare-test-datasource.ts",
|
|
35
33
|
"test": "vitest"
|
|
36
34
|
},
|
|
37
35
|
"peerDependencies": {
|