diff --git a/package-lock.json b/package-lock.json index 4c63854..24c5b18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "leaflet.locatecontrol": "^0.79.0", "normalize.css": "^8.0.1", "opening_hours": "^3.8.0", - "osm-auth": "^1.1.0", + "osm-auth": "^2.4.0", "osm-parking-tag-updater": "github:osmberlin/osm-tag-updater", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -9556,15 +9556,6 @@ "node": ">=4" } }, - "node_modules/jshashes": { - "version": "1.0.8", - "bin": { - "hashes": "bin/hashes" - }, - "engines": { - "node": "*" - } - }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "dev": true, @@ -10218,16 +10209,6 @@ "dev": true, "license": "MIT" }, - "node_modules/ohauth": { - "version": "1.0.1", - "license": "ISC", - "dependencies": { - "jshashes": "~1.0.8" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/on-finished": { "version": "2.4.1", "dev": true, @@ -10320,15 +10301,11 @@ } }, "node_modules/osm-auth": { - "version": "1.1.2", - "license": "ISC", - "dependencies": { - "ohauth": "~1.0.1", - "resolve-url": "~0.2.1", - "store": "~2.0.12" - }, + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/osm-auth/-/osm-auth-2.4.0.tgz", + "integrity": "sha512-FvTyYnIl+pjLi9cKJWNM74PjrLUED1f2TnWpAexxJ2qoxr8sdndON/EzXHf0nfMLB07Pn9DPyWVEbTXZ/nID8A==", "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/osm-parking-tag-updater": { @@ -12142,10 +12119,6 @@ "node": ">=8" } }, - "node_modules/resolve-url": { - "version": "0.2.1", - "license": "MIT" - }, "node_modules/resolve.exports": { "version": "2.0.0", "dev": true, @@ -12668,13 +12641,6 @@ "node": ">= 0.4" } }, - "node_modules/store": { - "version": "2.0.12", - "license": "MIT", - "engines": { - "node": "*" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "dev": true, diff --git a/package.json b/package.json index 28d7bae..a9a6637 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "leaflet.locatecontrol": "^0.79.0", "normalize.css": "^8.0.1", "opening_hours": "^3.8.0", - "osm-auth": "^1.1.0", + "osm-auth": "^2.4.0", "osm-parking-tag-updater": "github:osmberlin/osm-tag-updater", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/utils/osm-client.ts b/src/utils/osm-client.ts index d350add..ffada97 100644 --- a/src/utils/osm-client.ts +++ b/src/utils/osm-client.ts @@ -1,27 +1,30 @@ import * as JXON from 'jxon' -import osmAuth from 'osm-auth' +import { osmAuth } from 'osm-auth' import { osmProdUrl, osmDevUrl } from './links' import { type OsmWay } from './types/osm-data' import { type ChangedIdMap, type ChangesStore, type JxonOsmWay } from './types/changes-store' -let auth: OSMAuth.OSMAuthInstance | null = null +let auth: OSMAuth.osmAuth | null = null function craeteOsmAuth(useDevServer: boolean) { return useDevServer ? - // Used to not have these new keywords // eslint-disable-next-line new-cap new osmAuth({ url: osmDevUrl, - oauth_consumer_key: 'FhbDyU5roZ0wAPffly1yfiYChg8RaNuFlJTB0SE1', - oauth_secret: 'gTzuFDWUqmZnwho2NIaVoxpgSX47Xyqq65lTw8do', + client_id: 'lX6vX5gKHEfLV9kybjRpy2L7BTqtwZ5c_G7sjKscVw0', + access_token: localStorage.getItem('https://master.apis.dev.openstreetmap.orgoauth2_access_token') ?? undefined, + redirect_uri: window.location.origin + window.location.pathname + 'land.html', + scope: 'read_prefs write_api', auto: true, }) : // eslint-disable-next-line new-cap new osmAuth({ url: osmProdUrl, - oauth_consumer_key: 'Np0gmfYoqo6Ronla4wuFTXEUgypODL0jPRzjiFW6', - oauth_secret: 'KnUDQ3sL3T7LZjvwi5OJj1hxNBz0UiSpTr0T0fLs', + client_id: 'wwP2hKLF5LAWQgZTcd8SjYXsCzd8zYvl7muuQm1V3Jo', + access_token: localStorage.getItem('https://openstreetmap.orgoauth2_access_token') ?? undefined, + redirect_uri: window.location.origin + window.location.pathname + 'land.html', + scope: 'read_prefs write_api', auto: true, }) } @@ -65,7 +68,7 @@ export function userInfo(): Promise { return osmXhr({ method: 'GET', path: '/api/0.6/user/details', - options: { header: { Accept: 'application/json' } }, + headers: { Accept: 'application/json' }, }) } @@ -122,7 +125,7 @@ function createChangeset(editorName: string, editorVersion: string): Promise