mirror of
https://github.com/github/awesome-copilot.git
synced 2026-08-13 12:49:49 +00:00
Harden persisted authentication recovery
Treat malformed authentication records as missing so browser sign-in can recover, preserve real file-read failures, and pin the Azure Identity persistence dependencies exactly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -28,14 +28,23 @@ let legacyAuthCacheRemoved = false;
|
||||
|
||||
useIdentityPlugin(cachePersistencePlugin);
|
||||
|
||||
async function loadAuthenticationRecord() {
|
||||
export async function loadAuthenticationRecord({
|
||||
readFile = fs.readFile,
|
||||
deserialize = deserializeAuthenticationRecord,
|
||||
authRecordFile = AUTH_RECORD_FILE,
|
||||
} = {}) {
|
||||
let serialized;
|
||||
try {
|
||||
const serialized = await fs.readFile(AUTH_RECORD_FILE, "utf-8");
|
||||
return deserializeAuthenticationRecord(serialized);
|
||||
serialized = await readFile(authRecordFile, "utf-8");
|
||||
} catch (error) {
|
||||
if (error?.code === "ENOENT") return undefined;
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
return deserialize(serialized);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveAuthenticationRecord(record) {
|
||||
|
||||
Reference in New Issue
Block a user