Merge branch 'dev'
CI/CD / deploy (push) Failing after 2m9s
Details
CI/CD / deploy (push) Failing after 2m9s
Details
This commit is contained in:
commit
f051a5a644
|
|
@ -195,7 +195,7 @@ export class RecoveryManager {
|
|||
throw new Error(err.error || `Server error: ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const data = await res.json().catch(() => ({}));
|
||||
serverId = data.guardian?.id;
|
||||
|
||||
console.log('EncryptID: Guardian added via server', {
|
||||
|
|
@ -345,7 +345,7 @@ export class RecoveryManager {
|
|||
});
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
const data = await res.json().catch(() => ({ guardians: [] }));
|
||||
const serverGuardian = data.guardians?.find((g: any) => g.id === guardianId);
|
||||
|
||||
if (!serverGuardian) {
|
||||
|
|
|
|||
|
|
@ -179,8 +179,9 @@ export class SessionManager {
|
|||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ credentialId: authResult.credentialId }),
|
||||
});
|
||||
if (!startRes.ok) throw new Error('Failed to start server auth');
|
||||
const { options } = await startRes.json();
|
||||
if (!startRes.ok) throw new Error(`Failed to start server auth: ${startRes.status}`);
|
||||
const startBody = await startRes.json().catch(() => { throw new Error('Invalid JSON from auth/start'); });
|
||||
const { options } = startBody;
|
||||
|
||||
// Step 2: Complete auth with credentialId to get signed token
|
||||
const completeRes = await fetch(`${ENCRYPTID_SERVER}/api/auth/complete`, {
|
||||
|
|
@ -191,8 +192,8 @@ export class SessionManager {
|
|||
credential: { credentialId: authResult.credentialId },
|
||||
}),
|
||||
});
|
||||
if (!completeRes.ok) throw new Error('Server auth failed');
|
||||
const data = await completeRes.json();
|
||||
if (!completeRes.ok) throw new Error(`Server auth failed: ${completeRes.status}`);
|
||||
const data = await completeRes.json().catch(() => { throw new Error('Invalid JSON from auth/complete'); });
|
||||
if (!data.token) throw new Error('No token in response');
|
||||
accessToken = data.token;
|
||||
} catch (err) {
|
||||
|
|
@ -544,7 +545,7 @@ export class SessionManager {
|
|||
});
|
||||
|
||||
if (!res.ok) throw new Error(`Refresh failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
const data = await res.json().catch(() => { throw new Error('Invalid JSON from session/refresh'); });
|
||||
if (!data.token) throw new Error('No token in refresh response');
|
||||
|
||||
// Decode new claims
|
||||
|
|
|
|||
|
|
@ -667,7 +667,9 @@ export class EncryptIDLoginButton extends HTMLElement {
|
|||
body: JSON.stringify({ username }),
|
||||
});
|
||||
if (!res.ok) return undefined;
|
||||
const { options, userFound } = await res.json();
|
||||
const body = await res.json().catch(() => null);
|
||||
if (!body) return undefined;
|
||||
const { options, userFound } = body;
|
||||
if (!userFound || !options.allowCredentials?.length) return undefined;
|
||||
return options.allowCredentials.map((c: any) => ({
|
||||
type: 'public-key' as const,
|
||||
|
|
|
|||
Loading…
Reference in New Issue