Skip to content

Commit

Permalink
change name, fix refreshTokens req, redux devtools off
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Dec 13, 2023
1 parent 07bb209 commit 8dfe930
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 112 deletions.
163 changes: 67 additions & 96 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "bento_auth_js",
"name": "bento-auth-js",
"version": "1.0.0",
"description": "Authentication library for web applications of Bento-Platform",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "npx tsc",
"lint": "npx eslint src",
"buildpack": "rm ./packs/*.tgz && tsc && npm pack --pack-destination ./packs"
"buildpack": "rm -f ./packs/*.tgz && tsc && npm pack --pack-destination ./packs"
},
"repository": {
"type": "git",
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ export {
default as OIDCReducer,
fetchOpenIdConfiguration
} from "./redux/openIdConfigSlice";

export { default as AuthStore } from "./redux/store";
3 changes: 1 addition & 2 deletions src/redux/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const refreshTokens = createAsyncThunk<any, string, {rejectValue: any}>(
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Bearer ${state.auth.accessToken}`,
},
body: buildUrlEncodedData({
grant_type: "refresh_token",
Expand Down Expand Up @@ -100,7 +99,7 @@ export const fetchResourcePermissions = createAsyncThunk<any, PermissionParams,
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${auth.accessToken}` },
body: JSON.stringify({ resources: resource }),
body: JSON.stringify({resources: [resource]}),
});
return await response.json();
},
Expand Down
13 changes: 3 additions & 10 deletions src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ import auth from "./authSlice";
import openIdConfiguration from "./openIdConfigSlice";
import { useDispatch } from "react-redux";

// This store is only created as a way to export its state and dispatch types
const authStore = configureStore({
reducer: {
auth,
openIdConfiguration,
}
},
devTools: false,
});

export type RootState = ReturnType<typeof authStore.getState>;

export type AppDispatch = typeof authStore.dispatch;
export const useAppDispatch: () => AppDispatch = useDispatch;

export type ThunkConfig = {
state: RootState
dispatch: AppDispatch
}

// export const createAppAsyncThunk = createAsyncThunk.withTypes<ThunkConfig>();

export default authStore;

0 comments on commit 8dfe930

Please sign in to comment.