codebyplan 1.13.59 → 1.13.60
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/cli.js +39 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -48,7 +48,7 @@ var VERSION, PACKAGE_NAME;
|
|
|
48
48
|
var init_version = __esm({
|
|
49
49
|
"src/lib/version.ts"() {
|
|
50
50
|
"use strict";
|
|
51
|
-
VERSION = "1.13.
|
|
51
|
+
VERSION = "1.13.60";
|
|
52
52
|
PACKAGE_NAME = "codebyplan";
|
|
53
53
|
}
|
|
54
54
|
});
|
|
@@ -880,29 +880,42 @@ async function deleteFallback(filename) {
|
|
|
880
880
|
} catch {
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
|
+
function useKeychain() {
|
|
884
|
+
const v = process.env.CODEBYPLAN_USE_KEYCHAIN;
|
|
885
|
+
return v === "1" || v === "true";
|
|
886
|
+
}
|
|
883
887
|
async function saveTokens(tokens) {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
888
|
+
if (useKeychain()) {
|
|
889
|
+
const Keyring = await loadKeyring();
|
|
890
|
+
if (Keyring) {
|
|
891
|
+
try {
|
|
892
|
+
new Keyring(SERVICE, TOKEN_ACCOUNT).setPassword(JSON.stringify(tokens));
|
|
893
|
+
return;
|
|
894
|
+
} catch {
|
|
895
|
+
}
|
|
890
896
|
}
|
|
891
897
|
}
|
|
892
898
|
await writeFallback("credentials.json", tokens);
|
|
893
899
|
}
|
|
894
900
|
async function loadTokens() {
|
|
901
|
+
const fromFile = await readFallback("credentials.json");
|
|
902
|
+
if (fromFile) return fromFile;
|
|
895
903
|
const Keyring = await loadKeyring();
|
|
896
904
|
if (Keyring) {
|
|
897
905
|
try {
|
|
898
906
|
const raw = new Keyring(SERVICE, TOKEN_ACCOUNT).getPassword();
|
|
899
|
-
if (raw)
|
|
907
|
+
if (raw) {
|
|
908
|
+
const tokens = JSON.parse(raw);
|
|
909
|
+
if (!useKeychain()) await writeFallback("credentials.json", tokens);
|
|
910
|
+
return tokens;
|
|
911
|
+
}
|
|
900
912
|
} catch {
|
|
901
913
|
}
|
|
902
914
|
}
|
|
903
|
-
return
|
|
915
|
+
return null;
|
|
904
916
|
}
|
|
905
917
|
async function clearTokens() {
|
|
918
|
+
await deleteFallback("credentials.json");
|
|
906
919
|
const Keyring = await loadKeyring();
|
|
907
920
|
if (Keyring) {
|
|
908
921
|
try {
|
|
@@ -910,31 +923,39 @@ async function clearTokens() {
|
|
|
910
923
|
} catch {
|
|
911
924
|
}
|
|
912
925
|
}
|
|
913
|
-
await deleteFallback("credentials.json");
|
|
914
926
|
}
|
|
915
927
|
async function saveClientRegistration(reg) {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
928
|
+
if (useKeychain()) {
|
|
929
|
+
const Keyring = await loadKeyring();
|
|
930
|
+
if (Keyring) {
|
|
931
|
+
try {
|
|
932
|
+
new Keyring(SERVICE, CLIENT_ACCOUNT).setPassword(JSON.stringify(reg));
|
|
933
|
+
return;
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
922
936
|
}
|
|
923
937
|
}
|
|
924
938
|
await writeFallback("client.json", reg);
|
|
925
939
|
}
|
|
926
940
|
async function loadClientRegistration() {
|
|
941
|
+
const fromFile = await readFallback("client.json");
|
|
942
|
+
if (fromFile) return fromFile;
|
|
927
943
|
const Keyring = await loadKeyring();
|
|
928
944
|
if (Keyring) {
|
|
929
945
|
try {
|
|
930
946
|
const raw = new Keyring(SERVICE, CLIENT_ACCOUNT).getPassword();
|
|
931
|
-
if (raw)
|
|
947
|
+
if (raw) {
|
|
948
|
+
const reg = JSON.parse(raw);
|
|
949
|
+
if (!useKeychain()) await writeFallback("client.json", reg);
|
|
950
|
+
return reg;
|
|
951
|
+
}
|
|
932
952
|
} catch {
|
|
933
953
|
}
|
|
934
954
|
}
|
|
935
|
-
return
|
|
955
|
+
return null;
|
|
936
956
|
}
|
|
937
957
|
async function clearClientRegistration() {
|
|
958
|
+
await deleteFallback("client.json");
|
|
938
959
|
const Keyring = await loadKeyring();
|
|
939
960
|
if (Keyring) {
|
|
940
961
|
try {
|
|
@@ -942,7 +963,6 @@ async function clearClientRegistration() {
|
|
|
942
963
|
} catch {
|
|
943
964
|
}
|
|
944
965
|
}
|
|
945
|
-
await deleteFallback("client.json");
|
|
946
966
|
}
|
|
947
967
|
var SERVICE, TOKEN_ACCOUNT, CLIENT_ACCOUNT, keyringOverride;
|
|
948
968
|
var init_keychain = __esm({
|