better-auth-studio 1.0.57 → 1.0.58-beta.2
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/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAyLhG;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAyLhG;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAgmKR"}
|
package/dist/routes.js
CHANGED
|
@@ -4704,13 +4704,26 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
4704
4704
|
const match = trimmed.match(/^([^=#]+)=(.*)$/);
|
|
4705
4705
|
if (match) {
|
|
4706
4706
|
const key = match[1].trim();
|
|
4707
|
-
|
|
4707
|
+
let value = match[2].trim();
|
|
4708
|
+
// Remove surrounding quotes if present (handles both single and double quotes)
|
|
4709
|
+
if (value.length >= 2) {
|
|
4710
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
4711
|
+
value = value.slice(1, -1).trim();
|
|
4712
|
+
}
|
|
4713
|
+
}
|
|
4708
4714
|
if (key === clientIdKey || key === clientSecretKey) {
|
|
4709
4715
|
existingCredentials[key] = value;
|
|
4710
4716
|
}
|
|
4711
4717
|
}
|
|
4712
4718
|
});
|
|
4713
|
-
|
|
4719
|
+
// Only consider it as existing if the values are not empty (after stripping quotes)
|
|
4720
|
+
const isValueEmpty = (val) => {
|
|
4721
|
+
if (!val)
|
|
4722
|
+
return true;
|
|
4723
|
+
return val.trim() === '';
|
|
4724
|
+
};
|
|
4725
|
+
const hasExisting = !isValueEmpty(existingCredentials[clientIdKey]) ||
|
|
4726
|
+
!isValueEmpty(existingCredentials[clientSecretKey]);
|
|
4714
4727
|
res.json({
|
|
4715
4728
|
success: true,
|
|
4716
4729
|
hasExisting,
|
|
@@ -4751,7 +4764,9 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
4751
4764
|
if (match) {
|
|
4752
4765
|
const key = match[1].trim();
|
|
4753
4766
|
const value = match[2].trim();
|
|
4754
|
-
|
|
4767
|
+
if (value.trim() !== '') {
|
|
4768
|
+
envMap.set(key, { line, index });
|
|
4769
|
+
}
|
|
4755
4770
|
newLines.push(line);
|
|
4756
4771
|
}
|
|
4757
4772
|
else {
|
|
@@ -4770,13 +4785,20 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
4770
4785
|
}
|
|
4771
4786
|
}
|
|
4772
4787
|
let updated = false;
|
|
4788
|
+
const clientIdLineIndex = envLines.findIndex((line) => {
|
|
4789
|
+
const trimmed = line.trim();
|
|
4790
|
+
return trimmed.startsWith(`${clientIdKey}=`);
|
|
4791
|
+
});
|
|
4773
4792
|
if (action === 'override' && envMap.has(clientIdKey)) {
|
|
4774
4793
|
const existing = envMap.get(clientIdKey);
|
|
4775
4794
|
newLines[existing.index] = `${clientIdKey}=${clientId}`;
|
|
4776
4795
|
updated = true;
|
|
4777
4796
|
}
|
|
4778
|
-
else if (!envMap.has(clientIdKey)) {
|
|
4779
|
-
|
|
4797
|
+
else if (clientIdLineIndex >= 0 && !envMap.has(clientIdKey)) {
|
|
4798
|
+
newLines[clientIdLineIndex] = `${clientIdKey}=${clientId}`;
|
|
4799
|
+
updated = true;
|
|
4800
|
+
}
|
|
4801
|
+
else if (!envMap.has(clientIdKey) && clientIdLineIndex < 0) {
|
|
4780
4802
|
while (newLines.length > 0 && !newLines[newLines.length - 1].trim()) {
|
|
4781
4803
|
newLines.pop();
|
|
4782
4804
|
}
|
|
@@ -4791,12 +4813,20 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
|
|
|
4791
4813
|
newLines.push(`${clientIdKey}=${clientId}`);
|
|
4792
4814
|
updated = true;
|
|
4793
4815
|
}
|
|
4816
|
+
const clientSecretLineIndex = envLines.findIndex((line) => {
|
|
4817
|
+
const trimmed = line.trim();
|
|
4818
|
+
return trimmed.startsWith(`${clientSecretKey}=`);
|
|
4819
|
+
});
|
|
4794
4820
|
if (action === 'override' && envMap.has(clientSecretKey)) {
|
|
4795
4821
|
const existing = envMap.get(clientSecretKey);
|
|
4796
4822
|
newLines[existing.index] = `${clientSecretKey}=${clientSecret}`;
|
|
4797
4823
|
updated = true;
|
|
4798
4824
|
}
|
|
4799
|
-
else if (!envMap.has(clientSecretKey)) {
|
|
4825
|
+
else if (clientSecretLineIndex >= 0 && !envMap.has(clientSecretKey)) {
|
|
4826
|
+
newLines[clientSecretLineIndex] = `${clientSecretKey}=${clientSecret}`;
|
|
4827
|
+
updated = true;
|
|
4828
|
+
}
|
|
4829
|
+
else if (!envMap.has(clientSecretKey) && clientSecretLineIndex < 0) {
|
|
4800
4830
|
const clientIdIndex = newLines.findIndex((line) => line.startsWith(`${clientIdKey}=`));
|
|
4801
4831
|
if (clientIdIndex >= 0) {
|
|
4802
4832
|
newLines.splice(clientIdIndex + 1, 0, `${clientSecretKey}=${clientSecret}`);
|