MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / resolveSnowflakeConfig

Function resolveSnowflakeConfig

apps/web/src/lib/snowflake.ts:59–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 * Returns `null` when any required variable is missing.
58 */
59export function resolveSnowflakeConfig(): SnowflakeConfig | null {
60 if (getMissingSnowflakeEnvKeys().length > 0) return null;
61
62 const privateKeyRaw = getEnvVariable('SNOWFLAKE_PRIVATE_KEY_PEM');
63 const fingerprint = getEnvVariable('SNOWFLAKE_PUBLIC_KEY_FINGERPRINT');
64 const accountHost = getEnvVariable('SNOWFLAKE_ACCOUNT_HOST');
65
66 return {
67 accountHost: accountHost
68 .trim()
69 .replace(/^https?:\/\//, '')
70 .replace(/\/$/, ''),
71 jwtAccountIdentifier: getEnvVariable('SNOWFLAKE_JWT_ACCOUNT_IDENTIFIER'),
72 username: getEnvVariable('SNOWFLAKE_USERNAME'),
73 role: getEnvVariable('SNOWFLAKE_ROLE'),
74 warehouse: getEnvVariable('SNOWFLAKE_WAREHOUSE'),
75 database: getEnvVariable('SNOWFLAKE_DATABASE'),
76 schema: getEnvVariable('SNOWFLAKE_SCHEMA'),
77 // Env vars often encode newlines as literal \n — normalise here.
78 privateKeyPem: privateKeyRaw.replace(/\\n/g, '\n'),
79 publicKeyFingerprint: fingerprint.startsWith('SHA256:') ? fingerprint : `SHA256:${fingerprint}`,
80 };
81}
82
83// ---------------------------------------------------------------------------
84// JWT

Callers 3

fetchReportFunction · 0.90

Calls 3

getEnvVariableFunction · 0.90
replaceMethod · 0.65

Tested by

no test coverage detected