Skip to content

Commit

Permalink
Upgrade osm-auth to 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
starsep committed Jan 9, 2024
1 parent 7a1701c commit 36f8c44
Show file tree
Hide file tree
Showing 8 changed files with 797 additions and 5,415 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
VITE_DEFAULT_LANG: en
VITE_OSM_API_URL: 'https://master.apis.dev.openstreetmap.org'
VITE_OSM_OAUTH2_CLIENT_ID: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_ID }}
VITE_OSM_OAUTH2_CLIENT_SECRET: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_SECRET }}
VITE_BACKEND_API_URL: 'https://dev.openaedmap.org'
run: npm run build && ./scripts/build_every_lang.sh
- name: Run deploy script on host
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
VITE_DEFAULT_LANG: en
VITE_OSM_API_URL: 'https://api.openstreetmap.org'
VITE_OSM_OAUTH2_CLIENT_ID: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_ID }}
VITE_OSM_OAUTH2_CLIENT_SECRET: ${{ secrets.REACT_APP_OSM_OAUTH2_CLIENT_SECRET }}
VITE_BACKEND_API_URL: 'https://openaedmap.org'
run: npm run build && ./scripts/build_every_lang.sh
- name: Run deploy script on host
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ VITE_DEFAULT_LANG=en
VITE_OSM_API_URL=https://master.apis.dev.openstreetmap.org
VITE_BACKEND_API_URL=https://dev.openaedmap.org
VITE_OSM_OAUTH2_CLIENT_ID=xXaPFXSLizLHuZzoLI1eebHncPdDdVH7nA917S9uFUo
VITE_OSM_OAUTH2_CLIENT_SECRET=vSfLjZquQ5xlcD9Lq9rhyDuH1ItpakgY5DW59WrRtHY
HOST=127.0.0.1
```

Expand Down
6,184 changes: 788 additions & 5,396 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"i18next-http-backend": "^2.4.2",
"maplibre-gl": "^3.6.2",
"opening_hours": "^3.8.0",
"osm-auth": "^2.3.0",
"osm-auth": "^2.4.0",
"react": "^18.1.0",
"react-bulma-components": "^4.1.0",
"react-dom": "^18.1.0",
Expand Down
13 changes: 3 additions & 10 deletions src/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// @ts-ignore
import { osmAuth } from "osm-auth";
import React, { Suspense, useEffect, useMemo, useState } from "react";
import { AppContext } from "~/appContext";
import { fetchCountriesData } from "~/backend";
import CustomModal from "~/components/modal";
import { useLanguage } from "~/i18n";
import { AuthState } from "~/model/auth";
import { Country } from "~/model/country";
import { DefibrillatorData } from "~/model/defibrillatorData";
Expand Down Expand Up @@ -35,21 +32,17 @@ function Main() {
setRightSidebarShown(!rightSidebarShown);
const closeRightSidebar = () => setRightSidebarShown(false);

const {
VITE_OSM_API_URL,
VITE_OSM_OAUTH2_CLIENT_ID,
VITE_OSM_OAUTH2_CLIENT_SECRET,
} = import.meta.env;
const { VITE_OSM_API_URL, VITE_OSM_OAUTH2_CLIENT_ID } = import.meta.env;
const redirectPath = window.location.origin + window.location.pathname;
const [auth] = useState(
osmAuth({
new osmAuth({
url: VITE_OSM_API_URL,
client_id: VITE_OSM_OAUTH2_CLIENT_ID ?? "",
client_secret: VITE_OSM_OAUTH2_CLIENT_SECRET ?? "",
redirect_uri: `${redirectPath}land.html`,
scope: "read_prefs write_api",
auto: false,
singlepage: false,
// @ts-ignore: https://github.com/osmlab/osm-auth/pull/127
apiUrl: VITE_OSM_API_URL,
}),
);
Expand Down
2 changes: 1 addition & 1 deletion src/model/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface AuthState {
auth: OSMAuth.OSMAuthInstance | null;
auth: OSMAuth.osmAuth | null;
osmUsername: string;
}

Expand Down
8 changes: 4 additions & 4 deletions src/osm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function fetchNodeDataFromOsm(
}

export function updateOsmUsernameState(
auth: OSMAuth.OSMAuthInstance,
auth: OSMAuth.osmAuth,
setOsmUsername: (username: string) => void,
) {
auth.xhr(
Expand All @@ -76,7 +76,7 @@ function createTagElement(key: string, value: string): Element {
}

export function getOpenChangesetId(
auth: OSMAuth.OSMAuthInstance,
auth: OSMAuth.osmAuth,
openChangesetId: string,
openChangesetIdSetter: (changesetId: string) => void,
lang: string,
Expand Down Expand Up @@ -131,7 +131,7 @@ export function getOpenChangesetId(
}

export function addDefibrillatorToOSM(
auth: OSMAuth.OSMAuthInstance,
auth: OSMAuth.osmAuth,
changesetId: string,
data: NewDefibrillatorData,
): Promise<string> {
Expand Down Expand Up @@ -172,7 +172,7 @@ export function addDefibrillatorToOSM(
}

export function editDefibrillatorInOSM(
auth: OSMAuth.OSMAuthInstance,
auth: OSMAuth.osmAuth,
changesetId: string,
data: DefibrillatorData,
): Promise<string> {
Expand Down

0 comments on commit 36f8c44

Please sign in to comment.