@malloy-publisher/server 0.0.129 → 0.0.130
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/app/api-doc.yaml +6 -0
- package/dist/app/assets/{HomePage-Qc68TNcO.js → HomePage-DY-5y7-O.js} +1 -1
- package/dist/app/assets/{MainPage-BqJViErq.js → MainPage-TMtFLxWp.js} +1 -1
- package/dist/app/assets/{ModelPage-jy5aqW4h.js → ModelPage-Bo88gQsL.js} +1 -1
- package/dist/app/assets/{PackagePage-HyA-5qLe.js → PackagePage-Cd3jRo6g.js} +1 -1
- package/dist/app/assets/{ProjectPage-0v0w0clo.js → ProjectPage-CDlHDzlk.js} +1 -1
- package/dist/app/assets/{RouteError-Cpci97vi.js → RouteError-D6xdH0VE.js} +1 -1
- package/dist/app/assets/{WorkbookPage-B-ThNL_I.js → WorkbookPage-im0REJvX.js} +1 -1
- package/dist/app/assets/{index-LMhiPgJ7.js → index-B7sMhQDb.js} +1 -1
- package/dist/app/assets/{index-CRTqY7A2.js → index-B81BV2U3.js} +4 -4
- package/dist/app/assets/{index-WCB9ETR1.js → index-BzxjSqrV.js} +1 -1
- package/dist/app/assets/{index.umd-CzfgaPy4.js → index.umd-CUL-Q1Jn.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/server.js +61 -3
- package/package.json +1 -1
- package/src/service/connection.ts +81 -3
|
@@ -143,6 +143,54 @@ function handleAlreadyAttachedError(error: unknown, dbName: string): void {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
function normalizePrivateKey(privateKey: string): string {
|
|
147
|
+
let privateKeyContent = privateKey.trim();
|
|
148
|
+
|
|
149
|
+
if (!privateKeyContent.includes("\n")) {
|
|
150
|
+
// Try encrypted key first, then unencrypted
|
|
151
|
+
const keyPatterns = [
|
|
152
|
+
{
|
|
153
|
+
beginRegex: /-----BEGIN\s+ENCRYPTED\s+PRIVATE\s+KEY-----/i,
|
|
154
|
+
endRegex: /-----END\s+ENCRYPTED\s+PRIVATE\s+KEY-----/i,
|
|
155
|
+
beginMarker: "-----BEGIN ENCRYPTED PRIVATE KEY-----",
|
|
156
|
+
endMarker: "-----END ENCRYPTED PRIVATE KEY-----",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
beginRegex: /-----BEGIN\s+PRIVATE\s+KEY-----/i,
|
|
160
|
+
endRegex: /-----END\s+PRIVATE\s+KEY-----/i,
|
|
161
|
+
beginMarker: "-----BEGIN PRIVATE KEY-----",
|
|
162
|
+
endMarker: "-----END PRIVATE KEY-----",
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
for (const pattern of keyPatterns) {
|
|
167
|
+
const beginMatch = privateKeyContent.match(pattern.beginRegex);
|
|
168
|
+
const endMatch = privateKeyContent.match(pattern.endRegex);
|
|
169
|
+
|
|
170
|
+
if (beginMatch && endMatch) {
|
|
171
|
+
const beginPos = beginMatch.index! + beginMatch[0].length;
|
|
172
|
+
const endPos = endMatch.index!;
|
|
173
|
+
const keyData = privateKeyContent
|
|
174
|
+
.substring(beginPos, endPos)
|
|
175
|
+
.replace(/\s+/g, "");
|
|
176
|
+
|
|
177
|
+
const lines: string[] = [];
|
|
178
|
+
for (let i = 0; i < keyData.length; i += 64) {
|
|
179
|
+
lines.push(keyData.slice(i, i + 64));
|
|
180
|
+
}
|
|
181
|
+
privateKeyContent = `${pattern.beginMarker}\n${lines.join("\n")}\n${pattern.endMarker}\n`;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
if (!privateKeyContent.endsWith("\n")) {
|
|
187
|
+
privateKeyContent += "\n";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return privateKeyContent;
|
|
192
|
+
}
|
|
193
|
+
|
|
146
194
|
// Database-specific attachment handlers
|
|
147
195
|
async function attachBigQuery(
|
|
148
196
|
connection: DuckDBConnection,
|
|
@@ -497,23 +545,53 @@ export async function createProjectConnections(
|
|
|
497
545
|
throw new Error("Snowflake username is required.");
|
|
498
546
|
}
|
|
499
547
|
|
|
500
|
-
if (
|
|
501
|
-
|
|
548
|
+
if (
|
|
549
|
+
!connection.snowflakeConnection.password &&
|
|
550
|
+
!connection.snowflakeConnection.privateKey
|
|
551
|
+
) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
"Snowflake password or private key or private key path is required.",
|
|
554
|
+
);
|
|
502
555
|
}
|
|
503
556
|
|
|
504
557
|
if (!connection.snowflakeConnection.warehouse) {
|
|
505
558
|
throw new Error("Snowflake warehouse is required.");
|
|
506
559
|
}
|
|
507
560
|
|
|
561
|
+
let privateKeyPath = undefined;
|
|
562
|
+
|
|
563
|
+
if (connection.snowflakeConnection.privateKey) {
|
|
564
|
+
privateKeyPath = path.join(
|
|
565
|
+
TEMP_DIR_PATH,
|
|
566
|
+
`${connection.name}-${uuidv4()}-private-key.pem`,
|
|
567
|
+
);
|
|
568
|
+
const normalizedKey = normalizePrivateKey(
|
|
569
|
+
connection.snowflakeConnection.privateKey as string,
|
|
570
|
+
);
|
|
571
|
+
await fs.writeFile(privateKeyPath, normalizedKey);
|
|
572
|
+
}
|
|
573
|
+
|
|
508
574
|
const snowflakeConnectionOptions = {
|
|
509
575
|
connOptions: {
|
|
510
576
|
account: connection.snowflakeConnection.account,
|
|
511
577
|
username: connection.snowflakeConnection.username,
|
|
512
|
-
password: connection.snowflakeConnection.password,
|
|
513
578
|
warehouse: connection.snowflakeConnection.warehouse,
|
|
514
579
|
database: connection.snowflakeConnection.database,
|
|
515
580
|
schema: connection.snowflakeConnection.schema,
|
|
516
581
|
role: connection.snowflakeConnection.role,
|
|
582
|
+
...(connection.snowflakeConnection.privateKey
|
|
583
|
+
? {
|
|
584
|
+
privateKeyPath: privateKeyPath,
|
|
585
|
+
authenticator: "SNOWFLAKE_JWT",
|
|
586
|
+
privateKeyPass:
|
|
587
|
+
connection.snowflakeConnection.privateKeyPass ||
|
|
588
|
+
undefined,
|
|
589
|
+
}
|
|
590
|
+
: {
|
|
591
|
+
password:
|
|
592
|
+
connection.snowflakeConnection.password ||
|
|
593
|
+
undefined,
|
|
594
|
+
}),
|
|
517
595
|
timeout:
|
|
518
596
|
connection.snowflakeConnection.responseTimeoutMilliseconds,
|
|
519
597
|
},
|