Socket
Socket
Sign inDemoInstall

@googlemaps/google-maps-services-js

Package Overview
Dependencies
20
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.3.39 to 3.3.40

dist/adapter.test.d.ts

3

dist/adapter.d.ts

@@ -17,4 +17,3 @@ /**

import { Status } from "./common";
import { AxiosRequestConfig, AxiosPromise } from "axios";
export declare function statusToCode(status: Status): number;
export declare const customAdapter: (config: AxiosRequestConfig) => AxiosPromise<any>;
export declare const customAdapter: import("axios").AxiosAdapter;

@@ -17,8 +17,9 @@ "use strict";

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.customAdapter = exports.statusToCode = void 0;
const settle = require("axios/lib/core/settle");
const defaults = require("axios/lib/defaults");
const transformData = require("axios/lib/core/transformData");
const common_1 = require("./common");
const axios_1 = __importDefault(require("axios"));
function statusToCode(status) {

@@ -54,16 +55,32 @@ switch (status) {

exports.statusToCode = statusToCode;
const customAdapter = (config) => new Promise((resolve, reject) => {
defaults
.adapter(config)
.then((r) => {
// unfortunately data is transformed after the adapter
r.data = transformData(r.data, r.headers, config.transformResponse);
if (r.status === 200 && r.data.status) {
r.status = statusToCode(r.data.status);
}
settle(resolve, reject, r);
})
.catch(reject);
function settle(resolve, reject, response) {
const validateStatus = response.config.validateStatus;
if (!response.status || !validateStatus || validateStatus(response.status)) {
resolve(response);
}
else {
reject(new axios_1.default.AxiosError('Request failed with status code ' + response.status, [axios_1.default.AxiosError.ERR_BAD_REQUEST, axios_1.default.AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
}
}
exports.customAdapter = axios_1.default.getAdapter(config => {
const httpAdapter = axios_1.default.getAdapter('http');
return new Promise((resolve, reject) => {
httpAdapter(config)
.then((r) => {
// unfortunately data is transformed after the adapter
let data = r.data;
if (config.transformResponse) {
const t = Array.isArray(config.transformResponse) ? config.transformResponse : [config.transformResponse];
for (let fn of t) {
data = fn.call(config, data, r.headers, r.status);
}
}
if (r.status === 200 && data.status) {
r.status = statusToCode(data.status);
}
settle(resolve, reject, r);
})
.catch(reject);
});
});
exports.customAdapter = customAdapter;
//# sourceMappingURL=adapter.js.map

@@ -17,5 +17,31 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = exports.defaultAxiosInstance = exports.X_GOOG_MAPS_EXPERIENCE_ID = exports.acceptEncoding = exports.userAgent = exports.defaultTimeout = exports.defaultHttpsAgent = exports.version = void 0;
const rax = require("retry-axios");
const rax = __importStar(require("retry-axios"));
const directions_1 = require("./directions");

@@ -37,3 +63,3 @@ const distance_1 = require("./distance");

const timezone_1 = require("./timezone");
const axios_1 = require("axios");
const axios_1 = __importDefault(require("axios"));
const agentkeepalive_1 = require("agentkeepalive");

@@ -40,0 +66,0 @@ const adapter_1 = require("./adapter");

@@ -56,3 +56,3 @@ "use strict";

Status["NOT_FOUND"] = "NOT_FOUND";
})(Status = exports.Status || (exports.Status = {}));
})(Status || (exports.Status = Status = {}));
var PlaceIdScope;

@@ -67,3 +67,3 @@ (function (PlaceIdScope) {

PlaceIdScope["GOOGLE"] = "GOOGLE";
})(PlaceIdScope = exports.PlaceIdScope || (exports.PlaceIdScope = {}));
})(PlaceIdScope || (exports.PlaceIdScope = PlaceIdScope = {}));
var PlaceInputType;

@@ -73,3 +73,3 @@ (function (PlaceInputType) {

PlaceInputType["phoneNumber"] = "phonenumber";
})(PlaceInputType = exports.PlaceInputType || (exports.PlaceInputType = {}));
})(PlaceInputType || (exports.PlaceInputType = PlaceInputType = {}));
/**

@@ -181,3 +181,3 @@ * Table 1: Types supported in place search and addition

PlaceType1["zoo"] = "zoo";
})(PlaceType1 = exports.PlaceType1 || (exports.PlaceType1 = {}));
})(PlaceType1 || (exports.PlaceType1 = PlaceType1 = {}));
/**

@@ -278,3 +278,3 @@ * Table 2: Additional types returned by the Places service

PlaceType2["town_square"] = "town_square";
})(PlaceType2 = exports.PlaceType2 || (exports.PlaceType2 = {}));
})(PlaceType2 || (exports.PlaceType2 = PlaceType2 = {}));
var AspectRatingType;

@@ -290,3 +290,3 @@ (function (AspectRatingType) {

AspectRatingType["service"] = "service";
})(AspectRatingType = exports.AspectRatingType || (exports.AspectRatingType = {}));
})(AspectRatingType || (exports.AspectRatingType = AspectRatingType = {}));
/**

@@ -422,3 +422,3 @@ * By default the API will attempt to load the most appropriate language based on the users location or browser settings.

Language["zh_TW"] = "zh-TW";
})(Language = exports.Language || (exports.Language = {}));
})(Language || (exports.Language = Language = {}));
/**

@@ -446,3 +446,3 @@ * When you calculate directions, you may specify the transportation mode to use.

TravelMode["transit"] = "transit";
})(TravelMode = exports.TravelMode || (exports.TravelMode = {}));
})(TravelMode || (exports.TravelMode = TravelMode = {}));
var TravelRestriction;

@@ -461,3 +461,3 @@ (function (TravelRestriction) {

TravelRestriction["indoor"] = "indoor";
})(TravelRestriction = exports.TravelRestriction || (exports.TravelRestriction = {}));
})(TravelRestriction || (exports.TravelRestriction = TravelRestriction = {}));
/**

@@ -473,3 +473,3 @@ * Directions results contain text within distance fields that may be displayed to the user to indicate the distance of

UnitSystem["imperial"] = "imperial";
})(UnitSystem = exports.UnitSystem || (exports.UnitSystem = {}));
})(UnitSystem || (exports.UnitSystem = UnitSystem = {}));
var TrafficModel;

@@ -492,3 +492,3 @@ (function (TrafficModel) {

TrafficModel["optimistic"] = "optimistic";
})(TrafficModel = exports.TrafficModel || (exports.TrafficModel = {}));
})(TrafficModel || (exports.TrafficModel = TrafficModel = {}));
var TransitMode;

@@ -509,3 +509,3 @@ (function (TransitMode) {

TransitMode["rail"] = "rail";
})(TransitMode = exports.TransitMode || (exports.TransitMode = {}));
})(TransitMode || (exports.TransitMode = TransitMode = {}));
var TransitRoutingPreference;

@@ -517,3 +517,3 @@ (function (TransitRoutingPreference) {

TransitRoutingPreference["fewer_transfers"] = "fewer_transfers";
})(TransitRoutingPreference = exports.TransitRoutingPreference || (exports.TransitRoutingPreference = {}));
})(TransitRoutingPreference || (exports.TransitRoutingPreference = TransitRoutingPreference = {}));
/**

@@ -560,3 +560,3 @@ * The `status` field within the Directions response object contains the status of the request, and may contain debugging information

DirectionsResponseStatus["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
})(DirectionsResponseStatus = exports.DirectionsResponseStatus || (exports.DirectionsResponseStatus = {}));
})(DirectionsResponseStatus || (exports.DirectionsResponseStatus = DirectionsResponseStatus = {}));
/**

@@ -604,3 +604,3 @@ * The `status` field within the Directions response object contains the status of the request, and may contain debugging information

DirectionsReponseStatus["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
})(DirectionsReponseStatus = exports.DirectionsReponseStatus || (exports.DirectionsReponseStatus = {}));
})(DirectionsReponseStatus || (exports.DirectionsReponseStatus = DirectionsReponseStatus = {}));
var GeocodedWaypointStatus;

@@ -615,3 +615,3 @@ (function (GeocodedWaypointStatus) {

GeocodedWaypointStatus["ZERO_RESULTS"] = "ZERO_RESULTS";
})(GeocodedWaypointStatus = exports.GeocodedWaypointStatus || (exports.GeocodedWaypointStatus = {}));
})(GeocodedWaypointStatus || (exports.GeocodedWaypointStatus = GeocodedWaypointStatus = {}));
exports.AddressType = Object.assign({}, PlaceType1, PlaceType2);

@@ -638,3 +638,3 @@ var Maneuver;

Maneuver["roundabout_right"] = "roundabout-right";
})(Maneuver = exports.Maneuver || (exports.Maneuver = {}));
})(Maneuver || (exports.Maneuver = Maneuver = {}));
/** @see https://developers.google.com/maps/documentation/directions/intro#VehicleType. */

@@ -680,3 +680,3 @@ var VehicleType;

VehicleType["OTHER"] = "OTHER";
})(VehicleType = exports.VehicleType || (exports.VehicleType = {}));
})(VehicleType || (exports.VehicleType = VehicleType = {}));
var GeocodingAddressComponentType;

@@ -706,3 +706,3 @@ (function (GeocodingAddressComponentType) {

GeocodingAddressComponentType["transit_station"] = "transit_station";
})(GeocodingAddressComponentType = exports.GeocodingAddressComponentType || (exports.GeocodingAddressComponentType = {}));
})(GeocodingAddressComponentType || (exports.GeocodingAddressComponentType = GeocodingAddressComponentType = {}));
var LocationType;

@@ -727,3 +727,3 @@ (function (LocationType) {

LocationType["APPROXIMATE"] = "APPROXIMATE";
})(LocationType = exports.LocationType || (exports.LocationType = {}));
})(LocationType || (exports.LocationType = LocationType = {}));
var RadioType;

@@ -735,3 +735,3 @@ (function (RadioType) {

RadioType["wcdma"] = "wcdma";
})(RadioType = exports.RadioType || (exports.RadioType = {}));
})(RadioType || (exports.RadioType = RadioType = {}));
//# sourceMappingURL=common.js.map

@@ -49,3 +49,3 @@ "use strict";

ReverseGeocodingLocationType["APPROXIMATE"] = "APPROXIMATE";
})(ReverseGeocodingLocationType = exports.ReverseGeocodingLocationType || (exports.ReverseGeocodingLocationType = {}));
})(ReverseGeocodingLocationType || (exports.ReverseGeocodingLocationType = ReverseGeocodingLocationType = {}));
exports.defaultUrl = "https://maps.googleapis.com/maps/api/geocode/json";

@@ -52,0 +52,0 @@ exports.defaultParamsSerializer = (0, serialize_1.serializer)({

@@ -66,3 +66,3 @@ "use strict";

GeolocateErrorReason["parseError"] = "parseError";
})(GeolocateErrorReason = exports.GeolocateErrorReason || (exports.GeolocateErrorReason = {}));
})(GeolocateErrorReason || (exports.GeolocateErrorReason = GeolocateErrorReason = {}));
exports.defaultUrl = "https://www.googleapis.com/geolocation/v1/geolocate";

@@ -69,0 +69,0 @@ function geolocate(_a, axiosInstance) {

@@ -58,3 +58,3 @@ "use strict";

PlaceAutocompleteType["cities"] = "(cities)";
})(PlaceAutocompleteType = exports.PlaceAutocompleteType || (exports.PlaceAutocompleteType = {}));
})(PlaceAutocompleteType || (exports.PlaceAutocompleteType = PlaceAutocompleteType = {}));
exports.defaultUrl = "https://maps.googleapis.com/maps/api/place/autocomplete/json";

@@ -61,0 +61,0 @@ exports.defaultParamsSerializer = (0, serialize_1.serializer)({

@@ -44,3 +44,3 @@ "use strict";

PlacesNearbyRanking["distance"] = "distance";
})(PlacesNearbyRanking = exports.PlacesNearbyRanking || (exports.PlacesNearbyRanking = {}));
})(PlacesNearbyRanking || (exports.PlacesNearbyRanking = PlacesNearbyRanking = {}));
exports.defaultUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json";

@@ -47,0 +47,0 @@ exports.defaultParamsSerializer = (0, serialize_1.serializer)({ location: serialize_1.latLngToString }, exports.defaultUrl);

@@ -17,2 +17,5 @@ "use strict";

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -22,3 +25,4 @@ exports.createPremiumPlanQueryString = exports.toTimestamp = exports.serializer = exports.latLngArrayToStringMaybeEncoded = exports.toLatLngLiteral = exports.latLngBoundsToString = exports.objectToString = exports.latLngToString = void 0;

const url_signature_1 = require("@googlemaps/url-signature");
const query_string_1 = require("query-string");
const query_string_1 = __importDefault(require("query-string"));
const qs = query_string_1.default.stringify;
const separator = "|";

@@ -118,3 +122,3 @@ function latLngToString(o) {

}
return (0, query_string_1.stringify)(serializedParams, queryStringOptions);
return qs(serializedParams, queryStringOptions);
};

@@ -138,3 +142,3 @@ }

delete serializedParams.client_secret;
const partialQueryString = (0, query_string_1.stringify)(serializedParams, queryStringOptions);
const partialQueryString = qs(serializedParams, queryStringOptions);
const unsignedUrl = `${baseUrl}?${partialQueryString}`;

@@ -141,0 +145,0 @@ const signature = (0, url_signature_1.createSignature)(unsignedUrl, clientSecret);

{
"name": "@googlemaps/google-maps-services-js",
"version": "3.3.39",
"version": "3.3.40",
"description": "Node.js client library for Google Maps API Web Services",

@@ -41,3 +41,3 @@ "keywords": [

"docs": "rm -rf docs/ && typedoc src/index.ts",
"prepare": "tsc",
"prepack": "tsc",
"test": "jest src",

@@ -50,15 +50,15 @@ "test:e2e": "jest e2e",

"agentkeepalive": "^4.1.0",
"axios": "^0.27.2",
"query-string": "^7.1.3",
"retry-axios": "^2.6.0"
"axios": "^1.5.1",
"query-string": "<8.x",
"retry-axios": "<3.x"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"@types/jest": "^29.5.5",
"@types/node": "^20.1.1",
"jest": "^27.0.0",
"jest": "^29.7.0",
"nock": "^13.0.4",
"prettier": "^3.0.0",
"ts-jest": "^27.0.5",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.0",
"typescript": "^4.0.0"
"typescript": "^5.2.2"
},

@@ -65,0 +65,0 @@ "publishConfig": {

@@ -17,3 +17,3 @@ /**

import * as nock from "nock";
import nock from "nock";

@@ -20,0 +20,0 @@ import { AxiosResponse } from "axios";

@@ -17,8 +17,7 @@ /**

import * as settle from "axios/lib/core/settle";
import * as defaults from "axios/lib/defaults";
import * as transformData from "axios/lib/core/transformData";
import { Status } from "./common";
import { AxiosRequestConfig, AxiosResponse, AxiosPromise } from "axios";
import axios from "axios";
import type {AxiosResponse} from "axios";
export function statusToCode(status: Status): number {

@@ -54,15 +53,41 @@ switch (status) {

export const customAdapter = (config: AxiosRequestConfig): AxiosPromise<any> =>
new Promise((resolve, reject) => {
defaults
.adapter(config)
.then((r: AxiosResponse) => {
// unfortunately data is transformed after the adapter
r.data = transformData(r.data, r.headers, config.transformResponse);
if (r.status === 200 && r.data.status) {
r.status = statusToCode(r.data.status);
}
settle(resolve, reject, r);
})
.catch(reject);
function settle(resolve, reject, response) {
const validateStatus = response.config.validateStatus;
if (!response.status || !validateStatus || validateStatus(response.status)) {
resolve(response);
} else {
reject(new axios.AxiosError(
'Request failed with status code ' + response.status,
[axios.AxiosError.ERR_BAD_REQUEST, axios.AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
response.config,
response.request,
response
));
}
}
export const customAdapter = axios.getAdapter(config => {
const httpAdapter = axios.getAdapter('http');
return new Promise((resolve, reject) => {
httpAdapter(config)
.then((r: AxiosResponse) => {
// unfortunately data is transformed after the adapter
let data = r.data;
if (config.transformResponse) {
const t = Array.isArray(config.transformResponse) ? config.transformResponse : [config.transformResponse];
for (let fn of t) {
data = fn.call(config, data, r.headers, r.status);
}
}
if (r.status === 200 && data.status) {
r.status = statusToCode(data.status);
}
settle(resolve, reject, r);
})
.catch(reject);
});
});

@@ -20,5 +20,7 @@ /**

import { encodePath } from "./util";
import { createSignature} from "@googlemaps/url-signature";
import { stringify as qs } from "query-string";
import {createSignature} from "@googlemaps/url-signature";
import queryString from 'query-string';
const qs = queryString.stringify;
const separator = "|";

@@ -25,0 +27,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc