@squadbase/connectors 0.0.11 → 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.d.ts CHANGED
@@ -161,6 +161,7 @@ declare const connectors: {
161
161
  role: ParameterDefinition;
162
162
  warehouse: ParameterDefinition;
163
163
  privateKeyBase64: ParameterDefinition;
164
+ privateKeyPassphrase: ParameterDefinition;
164
165
  }, {
165
166
  executeQuery: ConnectorTool<{
166
167
  connectionId: string;
@@ -481,6 +482,7 @@ declare const snowflakeConnector: ConnectorPlugin<{
481
482
  role: ParameterDefinition;
482
483
  warehouse: ParameterDefinition;
483
484
  privateKeyBase64: ParameterDefinition;
485
+ privateKeyPassphrase: ParameterDefinition;
484
486
  }, {
485
487
  executeQuery: ConnectorTool<{
486
488
  connectionId: string;
package/dist/index.js CHANGED
@@ -271,11 +271,33 @@ var parameters3 = {
271
271
  type: "base64EncodedText",
272
272
  secret: true,
273
273
  required: true
274
+ }),
275
+ privateKeyPassphrase: new ParameterDefinition({
276
+ slug: "private-key-passphrase",
277
+ name: "Snowflake Private Key Passphrase",
278
+ description: "The passphrase for decrypting an encrypted private key. Leave empty if the key is not encrypted.",
279
+ envVarBaseKey: "SNOWFLAKE_PRIVATE_KEY_PASSPHRASE",
280
+ type: "text",
281
+ secret: true,
282
+ required: false
274
283
  })
275
284
  };
276
285
 
277
286
  // src/connectors/snowflake/tools/execute-query.ts
278
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
279
301
  var MAX_ROWS = 500;
280
302
  var QUERY_TIMEOUT_MS = 6e4;
281
303
  var inputSchema = z.object({
@@ -325,9 +347,11 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
325
347
  const role = parameters3.role.getValue(connection);
326
348
  const warehouse = parameters3.warehouse.getValue(connection);
327
349
  const privateKeyBase64 = parameters3.privateKeyBase64.getValue(connection);
328
- const privateKey = Buffer.from(privateKeyBase64, "base64").toString(
350
+ const privateKeyPem = Buffer.from(privateKeyBase64, "base64").toString(
329
351
  "utf-8"
330
352
  );
353
+ const privateKeyPass = parameters3.privateKeyPassphrase.tryGetValue(connection);
354
+ const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass ?? void 0);
331
355
  const conn = snowflake.createConnection({
332
356
  account,
333
357
  username: user,
@@ -407,10 +431,12 @@ var snowflakeConnector = new ConnectorPlugin({
407
431
  try {
408
432
  const snowflake = (await import("snowflake-sdk")).default;
409
433
  snowflake.configure({ logLevel: "ERROR" });
410
- const privateKey = Buffer.from(
434
+ const privateKeyPem = Buffer.from(
411
435
  params[parameters3.privateKeyBase64.slug],
412
436
  "base64"
413
437
  ).toString("utf-8");
438
+ const privateKeyPass = params[parameters3.privateKeyPassphrase.slug] || void 0;
439
+ const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass);
414
440
  const conn = snowflake.createConnection({
415
441
  account: params[parameters3.account.slug],
416
442
  username: params[parameters3.user.slug],
@@ -446,10 +472,12 @@ var snowflakeConnector = new ConnectorPlugin({
446
472
  const resolvedSql = replaceLiteralParams(sql, namedParams);
447
473
  const snowflake = (await import("snowflake-sdk")).default;
448
474
  snowflake.configure({ logLevel: "ERROR" });
449
- const privateKey = Buffer.from(
475
+ const privateKeyPem = Buffer.from(
450
476
  params[parameters3.privateKeyBase64.slug],
451
477
  "base64"
452
478
  ).toString("utf-8");
479
+ const privateKeyPass = params[parameters3.privateKeyPassphrase.slug] || void 0;
480
+ const privateKey = decryptPrivateKey(privateKeyPem, privateKeyPass);
453
481
  const conn = snowflake.createConnection({
454
482
  account: params[parameters3.account.slug],
455
483
  username: params[parameters3.user.slug],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/connectors",
3
- "version": "0.0.11",
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": {