add auth
This commit is contained in:
@@ -8,6 +8,13 @@ export interface KeyValue {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
type: 'none' | 'basic' | 'bearer' | 'api_key';
|
||||
basic: { username: '', password: '' };
|
||||
bearer: { token: '' };
|
||||
apiKey: { key: '', value: '', addTo: 'header' | 'query' };
|
||||
}
|
||||
|
||||
export interface RequestData {
|
||||
id: string;
|
||||
method: string;
|
||||
@@ -15,6 +22,7 @@ export interface RequestData {
|
||||
params: KeyValue[];
|
||||
headers: KeyValue[];
|
||||
body: string;
|
||||
auth: AuthState;
|
||||
response?: {
|
||||
status: number;
|
||||
headers: Record<string, string>;
|
||||
@@ -39,6 +47,12 @@ export const useRequestStore = defineStore('request', () => {
|
||||
{ id: crypto.randomUUID(), key: '', value: '', enabled: true }
|
||||
],
|
||||
body: '',
|
||||
auth: {
|
||||
type: 'none',
|
||||
basic: { username: '', password: '' },
|
||||
bearer: { token: '' },
|
||||
apiKey: { key: '', value: '', addTo: 'header' }
|
||||
},
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
|
||||
@@ -81,6 +95,16 @@ export const useRequestStore = defineStore('request', () => {
|
||||
if (loaded.params.length === 0) loaded.params.push({ id: crypto.randomUUID(), key: '', value: '', enabled: true });
|
||||
if (loaded.headers.length === 0) loaded.headers.push({ id: crypto.randomUUID(), key: '', value: '', enabled: true });
|
||||
|
||||
// Ensure auth object exists (migration for old history)
|
||||
if (!loaded.auth) {
|
||||
loaded.auth = {
|
||||
type: 'none',
|
||||
basic: { username: '', password: '' },
|
||||
bearer: { token: '' },
|
||||
apiKey: { key: '', value: '', addTo: 'header' }
|
||||
};
|
||||
}
|
||||
|
||||
activeRequest.value = loaded;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user