New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

osm-request

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osm-request - npm Package Compare versions

Comparing version 1.2.10 to 2.0.0

dist/OsmRequest.js.map

87

package.json
{
"name": "osm-request",
"description": "Request the OSM API from Javascript, with promises :)",
"version": "1.2.10",
"version": "2.0.0",
"homepage": "https://github.com/osmlab/osm-request/",

@@ -28,7 +28,7 @@ "repository": "https://github.com/osmlab/osm-request/",

"precommit": "lint-staged",
"test": "cross-env NODE_PATH=src jest --env=jsdom",
"test": "cross-env NODE_PATH=src jest",
"test-watch": "npm test -- --coverage --watch",
"test-ci": "npm test -- --ci --coverage",
"test-prettier": "prettier --single-quote --list-different 'src/**/*.{js,json}'",
"lint": "eslint 'src/**/*.{js,json}'",
"test-prettier": "prettier --config .prettierrc --list-different \"src/**/*.{js,json}\"",
"lint": "eslint \"src/**/*.{js,json}\"",
"doc": "npm run doc:lint && documentation build ./src/* -f md > API.md",

@@ -39,62 +39,31 @@ "doc:lint": "documentation lint ./src/*",

},
"jest": {
"collectCoverageFrom": [
"src/**/*.js",
"!<rootDir>/node_modules/"
],
"coveragePathIgnorePatterns": [
"<rootDir>/src/requests.js",
"<rootDir>/src/helpers/time.js",
"<rootDir>/node_modules/"
],
"coverageReporters": [
"json",
"lcov"
],
"verbose": true,
"testURL": "http://localhost/"
},
"prettier": {
"semi": true,
"singleQuote": true
},
"lint-staged": {
"src/**/*.{js,json}": [
"prettier --single-quote --write",
"eslint",
"git add"
],
"src/**/*.js": [
"npm run test-ci -- --findRelatedTests",
"npm run doc",
"git add API.md"
]
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"coveralls": "^3.1.0",
"cross-env": "^5.2.1",
"documentation": "^6.3.3",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.10.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^21.27.2",
"eslint-plugin-json": "^1.4.0",
"husky": "^0.14.3",
"babel-jest": "22.4.3",
"jest": "22.4.3",
"lint-staged": "^7.3.0",
"prettier": "^1.19.1",
"webpack": "^3.12.0"
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"babel-jest": "29.7.0",
"babel-loader": "^9.1.3",
"core-js": "^3.37.1",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"documentation": "^14.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-json": "^4.0.0",
"husky": "^9.0.11",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
"webpack": "^5.92.1",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"cross-fetch": "^3.0.5",
"osm-auth": "^1.1.0",
"xml2js": "^0.4.23",
"cross-fetch": "^4.0.0",
"osm-auth": "^2.5.0",
"xml2js": "^0.6.2",
"xmlserializer": "^0.6.1"
}
}

@@ -10,12 +10,8 @@ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**⚠ That project is in an heavy development phase. Do not use it until the first stable release.**
## Installation
```sh
$ npm install osm-request
npm install osm-request
```
## Usage

@@ -25,19 +21,54 @@

### Example
OSM Request use the same configurations properties as [osm-auth 2.5.0](https://github.com/osmlab/osm-auth). So you can define your options in a constante conf variable and use it both for osm-request and osm-auth.
### Register your OAuth 2 application
1. Open https://www.openstreetmap.org/oauth2/applications
2. Click on `Register new application`
3. Choose a `name` for your app, example: `demo-app`
4. Choose a `Redirect URI`
- For development, you can choose https://localhost and some port, it should be https.
- For production, you can choose the url of your app, it should be https.
5. Choose the permission you need for your app.
- read_prefs is the minimum
- write_api is needed if your app can edit data
6. Consider choosing more permissions if needed
- Read user preferences (read_prefs)
- Modify user preferences (write_prefs)
- Create diary entries, comments and make friends (write_diary)
- Modify the map (write_api)
- Read private GPS traces (read_gpx)
- Upload GPS traces (write_gpx)
- Modify notes (write_notes)
- Redact map data (write_redactions)
- Sign-in using OpenStreetMap (openid)
7. Click on `Register`
8. Make sure to copy the `Client ID`
9. The `Client Secret` is not needed, no need to copy it, also make sure not to disclose it
Note that OAuth 2.0 do no need the `Client Secret` to work. So it is safe to publish the `Client ID` of your app online. For example, you can create a browser/JavaScript app containing your `Client ID` and publish it online (on GitHub pages, etc).
### Example with single page and auto login form
The bellow example only show how to use osm-request. But to work, it needs first that you connect the user of your app to OSM throught osm-auth. To connect your user, please read osm-auth [readme](https://github.com/osmlab/osm-auth)
```javascript
import OsmRequest from 'osm-request';
const osm = new OsmRequest({
endpoint: 'https://www.openstreetmap.org',
oauthConsumerKey: '...',
oauthSecret: '...',
oauthUserToken: '...',
oauthUserTokenSecret: '...',
});
const conf = {
scope: 'read_prefs write_api', // To customize
client_id: "YOUR_CLIENT_ID", // To customize
redirect_uri: '',
url: 'https://www.openstreetmap.org',
apiUrl: 'https://api.openstreetmap.org',
auto: true,
singlepage: true
};
const osmRequest = new OsmRequest(conf);
async function start() {
let element = await osm.fetchElement('node/3683625932');
element = osm.setProperty(element, 'key', 'value');
element = osm.setProperties(element, {
let element = await osmRequest.fetchElement('node/3683625932');
element = osmRequest.setTag(element, 'key', 'value');
element = osmRequest.setTags(element, {
key1: 'value1',

@@ -47,10 +78,10 @@ key2: 'value2',

});
element = osm.removeProperty(element, 'key2');
element = osm.setTimestampToNow(element);
element = osm.setCoordinates(element, 1.234, 0.456);
element = osmRequest.removeTag(element, 'key2');
element = osmRequest.setTimestampToNow(element);
element = osmRequest.setCoordinates(element, 1.234, 0.456);
const changesetId = await osm.createChangeset('Created by me', 'My changeset comment');
const isChangesetStillOpen = await osm.isChangesetStillOpen(changesetId);
const newElementVersion = await osm.sendElement(element, changesetId);
element = osm.setVersion(element, newElementVersion);
const changesetId = await osmRequest.createChangeset('Created by me', 'My changeset comment');
const isChangesetStillOpen = await osmRequest.isChangesetStillOpen(changesetId);
const newElementVersion = await osmRequest.sendElement(element, changesetId);
element = osmRequest.setVersion(element, newElementVersion);
}

@@ -61,5 +92,4 @@

For the OSM dev instance, use that endpoint: https://api06.dev.openstreetmap.org
For the OSM dev instance, use that apiUrl: https://api06.dev.openstreetmap.org
## Contribute

@@ -70,6 +100,6 @@

```sh
$ git clone git@github.com:osmlab/osm-request.git
$ cd osm-request
$ npm install
$ npm run watch
git clone git@github.com:osmlab/osm-request.git
cd osm-request
npm install
npm run watch
```

@@ -85,16 +115,35 @@

### eslint version 8.X
For now eslint stays in version 8.X. We need to wait until babel, babel plugins and eslint plugins (that we use), are compatibles with version 9.X of eslint.
## Make a release
```sh
$ git checkout develop
$ git pull origin develop
$ npm version patch -m "release: %s"
$ npm publish
$ git checkout master
$ git pull origin master
$ git merge develop
$ git push origin master
git checkout develop
git pull origin develop
npm version patch -m "release: %s"
npm publish
git checkout master
git pull origin master
git merge develop
git push origin master
```
`npm version` tests the code, builds it and updates the doc. Then it upgrades the package version number according to the used keyword (patch, minor or major) and commits the modifications in Git (with a proper version tag). Finally, it pushes it to repository with the tag.
`npm version` tests the code, builds it and updates the doc. Then it upgrades the package version number according to the used keyword (patch, minor or major) and commits the modifications in Git (with a proper version tag). Finally, it pushes it to repository with the tag.
## Apps or libs using osm-request
- [Balluchon](https://gitlab.limos.fr/iia_braikeh/balluchon)
- [BANCO](https://github.com/PanierAvide/EditeurCommercesOSMFR)
- [Bike Ottawa Interactive Maps](https://github.com/BikeOttawa/maps.bikeottawa.ca-frontend)
- [Busy-Hours](https://github.com/Jungle-Bus/Busy-Hours)
- [Ça reste ouvert](https://github.com/caresteouvert/caresteouvert_backend)
- [OSM Mobile tag it](https://github.com/toutpt/osm-mobile-tagit)
- [osm-edit-bundle](https://www.npmjs.com/package/osm-edit-bundle)
- [OsmInEdit](https://framagit.org/PanierAvide/osminedit)
- [Parking Mapper](https://github.com/Binnette/parking-mapper)
- [Pic4Review](https://framagit.org/Pic4Carto/Pic4Review)
- [POIEditor](https://github.com/francois2metz/poieditor)
- [ProjetDuMois](https://github.com/vdct/ProjetDuMois)
- [tumulus](https://github.com/superrache/tumulus)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc