From 24493df182554d61814f2f1af1fa368a1a291c8c Mon Sep 17 00:00:00 2001 From: David Goemans Date: Fri, 2 Dec 2022 12:12:16 +0100 Subject: [PATCH] Allow credentials override --- .idea/.gitignore | 5 ++ .idea/codeStyles/Project.xml | 53 ++++++++++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .idea/inspectionProfiles/Project_Default.xml | 6 +++ .idea/modules.xml | 8 +++ .idea/spot.iml | 12 +++++ .idea/vcs.xml | 6 +++ src/fetch-middleware.ts | 2 + src/types.ts | 1 + 9 files changed, 98 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/spot.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..c3dc0fc --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,53 @@ + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8d0f972 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/spot.iml b/.idea/spot.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/.idea/spot.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/fetch-middleware.ts b/src/fetch-middleware.ts index d74bb26..df8262a 100644 --- a/src/fetch-middleware.ts +++ b/src/fetch-middleware.ts @@ -29,6 +29,7 @@ export const fetchMiddleware = (api: MiddlewareAPI) => (next: Dispatch) => async const response = await fetch(url, { ...defaultFetchConfig, method: action?.config?.method ?? 'GET', + credentials: action?.config?.credentials ?? 'same-origin', headers: { ...defaultFetchConfig.headers, authorization: action.config?.authorization || '', @@ -89,6 +90,7 @@ export const fetchMiddleware = (api: MiddlewareAPI) => (next: Dispatch) => async const response = await fetch(url, { ...defaultFetchConfig, method: action?.config?.method ?? 'POST', + credentials: action?.config?.credentials ?? 'same-origin', body: JSON.stringify(action.payload.params), headers: { ...defaultFetchConfig.headers, diff --git a/src/types.ts b/src/types.ts index 0906f2e..2731440 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,6 +5,7 @@ export type ActionType = 'SETUP' | 'ERROR' | 'QUERY' | 'COMMAND' | 'QUERY_COMPLE export interface ActionConfig { method?: string; authorization?: string; + credentials?: RequestCredentials; } export interface Action {