mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat(issueProvider): remove jira pat and wonkyCookie modes #2528
This commit is contained in:
parent
bc4123e742
commit
67b54307c6
7 changed files with 12 additions and 65 deletions
2
electron/electronAPI.d.ts
vendored
2
electron/electronAPI.d.ts
vendored
|
|
@ -100,7 +100,7 @@ export interface ElectronAPI {
|
|||
jiraCfg: JiraCfg;
|
||||
}): void;
|
||||
|
||||
jiraSetupImgHeaders(args: { jiraCfg: JiraCfg; wonkyCookie?: string }): void;
|
||||
jiraSetupImgHeaders(args: { jiraCfg: JiraCfg }): void;
|
||||
|
||||
backupAppData(appData: AppDataComplete): void;
|
||||
|
||||
|
|
|
|||
|
|
@ -71,12 +71,9 @@ export const initIpcInterfaces = (): void => {
|
|||
registerShowAppShortCuts(cfg);
|
||||
});
|
||||
|
||||
ipcMain.on(
|
||||
IPC.JIRA_SETUP_IMG_HEADERS,
|
||||
(ev, { jiraCfg, wonkyCookie }: { jiraCfg: JiraCfg; wonkyCookie?: string }) => {
|
||||
setupRequestHeadersForImages(jiraCfg, wonkyCookie);
|
||||
},
|
||||
);
|
||||
ipcMain.on(IPC.JIRA_SETUP_IMG_HEADERS, (ev, { jiraCfg }: { jiraCfg: JiraCfg }) => {
|
||||
setupRequestHeadersForImages(jiraCfg);
|
||||
});
|
||||
|
||||
ipcMain.on(IPC.JIRA_MAKE_REQUEST_EVENT, (ev, request) => {
|
||||
sendJiraRequest(request);
|
||||
|
|
|
|||
|
|
@ -76,10 +76,7 @@ export const sendJiraRequest = ({
|
|||
};
|
||||
|
||||
// TODO simplify and do encoding in frontend service
|
||||
export const setupRequestHeadersForImages = (
|
||||
jiraCfg: JiraCfg,
|
||||
wonkyCookie?: string,
|
||||
): void => {
|
||||
export const setupRequestHeadersForImages = (jiraCfg: JiraCfg): void => {
|
||||
const { host, protocol } = parseHostAndPort(jiraCfg);
|
||||
|
||||
// TODO export to util fn
|
||||
|
|
@ -91,22 +88,10 @@ export const setupRequestHeadersForImages = (
|
|||
urls: [`${protocol}://${host}/*`],
|
||||
};
|
||||
|
||||
if (jiraCfg.isWonkyCookieMode && !wonkyCookie) {
|
||||
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
|
||||
callback({ cancel: true });
|
||||
});
|
||||
}
|
||||
|
||||
// thankfully only the last attached listener will be used
|
||||
// @see: https://electronjs.org/docs/api/web-request
|
||||
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
|
||||
if (wonkyCookie && jiraCfg.isWonkyCookieMode) {
|
||||
details.requestHeaders.Cookie = wonkyCookie;
|
||||
} else if (jiraCfg.usePAT) {
|
||||
details.requestHeaders.authorization = `Bearer ${jiraCfg.password}`;
|
||||
} else {
|
||||
details.requestHeaders.authorization = `Basic ${encoded}`;
|
||||
}
|
||||
details.requestHeaders.authorization = `Basic ${encoded}`;
|
||||
callback({ requestHeaders: details.requestHeaders });
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -388,9 +388,6 @@ export class JiraApiService {
|
|||
}): Observable<any> {
|
||||
return this._isInterfacesReadyIfNeeded$.pipe(
|
||||
take(1),
|
||||
concatMap(() =>
|
||||
IS_ELECTRON && cfg.isWonkyCookieMode ? this._checkSetWonkyCookie(cfg) : of(true),
|
||||
),
|
||||
concatMap(() => {
|
||||
// assign uuid to request to know which responsive belongs to which promise
|
||||
const requestId = `${jiraReqCfg.pathname}__${
|
||||
|
|
@ -545,21 +542,12 @@ export class JiraApiService {
|
|||
headers: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
'Content-Type': 'application/json',
|
||||
...(IS_ELECTRON && cfg.isWonkyCookieMode
|
||||
? {
|
||||
Cookie: sessionStorage.getItem(SS.JIRA_WONKY_COOKIE) as string,
|
||||
}
|
||||
: cfg.usePAT
|
||||
? {
|
||||
Cookie: '',
|
||||
authorization: `Bearer ${cfg.password}`,
|
||||
}
|
||||
: {
|
||||
Cookie: '',
|
||||
authorization: `Basic ${this._b64EncodeUnicode(
|
||||
`${cfg.userName}:${cfg.password}`,
|
||||
)}`,
|
||||
}),
|
||||
...{
|
||||
Cookie: '',
|
||||
authorization: `Basic ${this._b64EncodeUnicode(
|
||||
`${cfg.userName}:${cfg.password}`,
|
||||
)}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ export const DEFAULT_JIRA_CFG: JiraCfg = {
|
|||
host: null,
|
||||
userName: null,
|
||||
password: null,
|
||||
isWonkyCookieMode: false,
|
||||
usePAT: false,
|
||||
|
||||
searchJqlQuery: '',
|
||||
|
||||
|
|
@ -198,21 +196,6 @@ export const JIRA_CONFIG_FORM_SECTION: ConfigFormSection<IssueProviderJira> = {
|
|||
// label: T.F.JIRA.FORM_CRED.ALLOW_SELF_SIGNED,
|
||||
// },
|
||||
// },
|
||||
{
|
||||
key: 'isWonkyCookieMode',
|
||||
type: 'checkbox',
|
||||
templateOptions: {
|
||||
label: T.F.JIRA.FORM_CRED.WONKY_COOKIE_MODE,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'usePAT',
|
||||
type: 'checkbox',
|
||||
templateOptions: {
|
||||
required: false,
|
||||
label: T.F.JIRA.FORM_CRED.USE_PAT,
|
||||
},
|
||||
},
|
||||
|
||||
...ISSUE_PROVIDER_COMMON_FORM_FIELDS,
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ export interface JiraCfg extends BaseIssueProviderCfg {
|
|||
host: string | null;
|
||||
userName: string | null;
|
||||
password?: string | null;
|
||||
isWonkyCookieMode: boolean;
|
||||
usePAT: boolean;
|
||||
|
||||
isAllowSelfSignedCertificate: boolean;
|
||||
searchJqlQuery: string;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ import { ICAL_TYPE, JIRA_TYPE } from '../../issue/issue.const';
|
|||
import { IS_ELECTRON } from '../../../app.constants';
|
||||
import { LayoutService } from '../../../core-ui/layout/layout.service';
|
||||
import { devError } from '../../../util/dev-error';
|
||||
import { SS } from '../../../core/persistence/storage-keys.const';
|
||||
import { IS_MOBILE } from '../../../util/is-mobile';
|
||||
import { GlobalConfigService } from '../../config/global-config.service';
|
||||
import { shareReplayUntil } from '../../../util/share-replay-until';
|
||||
|
|
@ -276,9 +275,6 @@ export class TaskDetailPanelComponent implements AfterViewInit, OnDestroy {
|
|||
if (jiraCfg.isEnabled) {
|
||||
window.ea.jiraSetupImgHeaders({
|
||||
jiraCfg,
|
||||
wonkyCookie: jiraCfg.isWonkyCookieMode
|
||||
? sessionStorage.getItem(SS.JIRA_WONKY_COOKIE) || undefined
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue