learn-secrets-sdk 1.8.0 → 1.10.0

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 (2) hide show
  1. package/dist/cli/index.mjs +50 -7
  2. package/package.json +1 -1
@@ -539,7 +539,7 @@ function parseEnvFile(filePath) {
539
539
  if (!trimmed || trimmed.startsWith("#")) {
540
540
  continue;
541
541
  }
542
- const match = trimmed.match(/^([A-Z0-9_]+)\s*=\s*(['"]?)(.+?)\2$/i);
542
+ const match = trimmed.match(/^([A-Z0-9_]+)\s*=\s*(['"]?)(.+)\2\s*$/i);
543
543
  if (match) {
544
544
  const key = match[1];
545
545
  const value = match[3];
@@ -585,6 +585,41 @@ var PROVIDER_PATTERNS = [
585
585
  baseUrl: "https://www.googleapis.com",
586
586
  authHeader: "Authorization",
587
587
  authPrefix: "Bearer "
588
+ },
589
+ {
590
+ pattern: /^AUTH0_.*_SECRET$/i,
591
+ provider: "auth0",
592
+ baseUrl: "",
593
+ authHeader: "Authorization",
594
+ authPrefix: "Bearer "
595
+ },
596
+ {
597
+ pattern: /^SPOTIFY_(CLIENT_ID|CLIENT_SECRET|API_KEY)$/i,
598
+ provider: "spotify",
599
+ baseUrl: "https://api.spotify.com",
600
+ authHeader: "Authorization",
601
+ authPrefix: "Bearer "
602
+ },
603
+ {
604
+ pattern: /^APPLE_(KEY_ID|TEAM_ID|P8_KEY)$/i,
605
+ provider: "apple",
606
+ baseUrl: "https://api.music.apple.com",
607
+ authHeader: "Authorization",
608
+ authPrefix: "Bearer "
609
+ },
610
+ {
611
+ pattern: /^LICHESS_KEY$/i,
612
+ provider: "lichess",
613
+ baseUrl: "https://lichess.org/api",
614
+ authHeader: "Authorization",
615
+ authPrefix: "Bearer "
616
+ },
617
+ {
618
+ pattern: /^GITHUB_PAT$/i,
619
+ provider: "github",
620
+ baseUrl: "https://api.github.com",
621
+ authHeader: "Authorization",
622
+ authPrefix: "Bearer "
588
623
  }
589
624
  ];
590
625
  function detectProvider(key) {
@@ -893,7 +928,8 @@ Next steps:`);
893
928
  console.log(` 2. Visit: ${dashboardUrl}/dashboard to manage secrets`);
894
929
  const config = {
895
930
  project: projectId,
896
- origins
931
+ origins,
932
+ env: envFile
897
933
  };
898
934
  fs3.writeFileSync(configFile, JSON.stringify(config, null, 2));
899
935
  console.log(`
@@ -920,15 +956,17 @@ async function configCommand(options) {
920
956
  process.exit(1);
921
957
  }
922
958
  const config = JSON.parse(fs4.readFileSync(configFile, "utf8"));
923
- if (!options.project && !options.origins) {
959
+ if (!options.project && !options.origins && !options.env) {
924
960
  console.log("\nCurrent configuration:");
925
961
  console.log(` Project ID: ${config.project || "(not set)"}`);
926
962
  console.log(` Origins: ${config.origins?.length > 0 ? config.origins.join(", ") : "(not set)"}`);
963
+ console.log(` Env file: ${config.env || ".env (default)"}`);
927
964
  console.log(`
928
965
  Config file: ${configFile}`);
929
966
  console.log("\nTo update:");
930
967
  console.log(" learn-secrets config --project <appid>");
931
968
  console.log(" learn-secrets config --origins domain1.com,domain2.com");
969
+ console.log(" learn-secrets config --env .custom_env");
932
970
  return;
933
971
  }
934
972
  let updated = false;
@@ -942,6 +980,11 @@ Config file: ${configFile}`);
942
980
  console.log(`Updated origins: ${config.origins.join(", ")}`);
943
981
  updated = true;
944
982
  }
983
+ if (options.env) {
984
+ config.env = options.env;
985
+ console.log(`Updated env file path: ${options.env}`);
986
+ updated = true;
987
+ }
945
988
  if (updated) {
946
989
  fs4.writeFileSync(configFile, JSON.stringify(config, null, 2));
947
990
  console.log(`
@@ -1058,7 +1101,7 @@ async function deployCommand(options = {}) {
1058
1101
  Deploying secrets to project: ${config.project}`);
1059
1102
  console.log(`Origins: ${config.origins.join(", ")}
1060
1103
  `);
1061
- const envFile = options.env || ".env";
1104
+ const envFile = options.env || config.env || ".env";
1062
1105
  let secrets;
1063
1106
  let envVars = [];
1064
1107
  try {
@@ -1113,7 +1156,7 @@ Deploying secrets to project: ${config.project}`);
1113
1156
  }
1114
1157
  const dashboardUrl = options.baseUrl || "https://cloudprototype.org";
1115
1158
  console.log(`
1116
- Secrets deployed! View them at: ${dashboardUrl}/dashboard/secrets/api_keys`);
1159
+ Secrets deployed! View them at: ${dashboardUrl}/dashboard/collections/secrets`);
1117
1160
  console.log("\n--- Cloudflare Worker Deployment ---");
1118
1161
  let cloudflareConnected = false;
1119
1162
  try {
@@ -1214,14 +1257,14 @@ Error: Worker deployment failed: ${provisionResult.error}`);
1214
1257
 
1215
1258
  // src/cli/index.ts
1216
1259
  var program = new Command();
1217
- program.name("learn-secrets").description("CLI tool for managing API secrets with Cloudflare Worker deployment").version("1.8.0");
1260
+ program.name("learn-secrets").description("CLI tool for managing API secrets with Cloudflare Worker deployment").version("1.10.0");
1218
1261
  program.command("login").description("Authenticate with Learn Secrets via browser").option("--base-url <url>", "Custom base URL for API").action(async (options) => {
1219
1262
  await loginCommand(options);
1220
1263
  });
1221
1264
  program.command("init").description("Initialize secrets for a new site").requiredOption("-o, --origins <domains>", "Comma-separated list of allowed origins (e.g., mysite.com,localhost)").option("-p, --project <appid>", "Project app ID (auto-detected from login if not specified)").option("-e, --env <file>", "Path to .env file (default: .env)", ".env").option("--base-url <url>", "Custom base URL for API").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
1222
1265
  await initCommand(options);
1223
1266
  });
1224
- program.command("config").description("View or update project configuration").option("-p, --project <appid>", "Change project ID").option("--origins <origins>", "Comma separated origins").action(async (options) => {
1267
+ program.command("config").description("View or update project configuration").option("-p, --project <appid>", "Change project ID").option("--origins <origins>", "Comma separated origins").option("-e, --env <file>", "Path to .env file").action(async (options) => {
1225
1268
  await configCommand(options);
1226
1269
  });
1227
1270
  program.command("deploy").description("Deploy secrets from .env to dashboard").option("-e, --env <file>", "Path to .env file (default: .env)", ".env").option("--base-url <url>", "Custom base URL for API").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learn-secrets-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Secure API proxy SDK with Cloudflare Worker deployment for static sites",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",