@googlemaps/google-maps-services-js
Advanced tools
Comparing version 3.2.6 to 3.3.0
@@ -33,2 +33,1 @@ /** | ||
}, queryStringOptions: object, baseUrl: string): string; | ||
export declare function createPremiumPlanSignature(unsignedUrl: string, clientSecret: string): string; |
@@ -18,7 +18,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPremiumPlanSignature = exports.createPremiumPlanQueryString = exports.toTimestamp = exports.serializer = exports.latLngArrayToStringMaybeEncoded = exports.toLatLngLiteral = exports.latLngBoundsToString = exports.objectToString = exports.latLngToString = void 0; | ||
exports.createPremiumPlanQueryString = exports.toTimestamp = exports.serializer = exports.latLngArrayToStringMaybeEncoded = exports.toLatLngLiteral = exports.latLngBoundsToString = exports.objectToString = exports.latLngToString = void 0; | ||
const util_1 = require("./util"); | ||
const CryptoJS = require("crypto-js"); | ||
const url_signature_1 = require("@googlemaps/url-signature"); | ||
const query_string_1 = require("query-string"); | ||
const url_1 = require("url"); | ||
const separator = "|"; | ||
@@ -139,3 +138,3 @@ function latLngToString(o) { | ||
const unsignedUrl = `${baseUrl}?${partialQueryString}`; | ||
const signature = createPremiumPlanSignature(unsignedUrl, clientSecret); | ||
const signature = (0, url_signature_1.createSignature)(unsignedUrl, clientSecret); | ||
// The signature must come last | ||
@@ -145,16 +144,2 @@ return `${partialQueryString}&signature=${signature}`; | ||
exports.createPremiumPlanQueryString = createPremiumPlanQueryString; | ||
function createPremiumPlanSignature(unsignedUrl, clientSecret) { | ||
// Strip off the protocol, scheme, and host portions of the URL, leaving only the path and the query | ||
const fullUrl = new url_1.URL(unsignedUrl); | ||
const pathAndQuery = `${fullUrl.pathname}${fullUrl.search}`; | ||
// Convert from 'web safe' base64 to true base64 | ||
const unsafeClientSecret = clientSecret.replace(/-/g, "+").replace(/_/g, "/"); | ||
// Base64 decode the secret | ||
const decodedSecret = CryptoJS.enc.Base64.parse(unsafeClientSecret); | ||
// Sign the url with the decoded secret | ||
const unsafeSignature = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA1, decodedSecret).update(pathAndQuery).finalize().toString(CryptoJS.enc.Base64); | ||
// Convert from true base64 to 'web safe' base64 | ||
return unsafeSignature.replace(/\+/g, "-").replace(/\//g, "_"); | ||
} | ||
exports.createPremiumPlanSignature = createPremiumPlanSignature; | ||
//# sourceMappingURL=serialize.js.map |
{ | ||
"name": "@googlemaps/google-maps-services-js", | ||
"version": "3.2.6", | ||
"version": "3.3.0", | ||
"description": "Node.js client library for Google Maps API Web Services", | ||
@@ -46,5 +46,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@googlemaps/url-signature": "^1.0.2", | ||
"agentkeepalive": "^4.1.0", | ||
"axios": "^0.21.1", | ||
"crypto-js": "4.1.1", | ||
"query-string": "^7.0.1", | ||
@@ -51,0 +51,0 @@ "retry-axios": "^2.2.1" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
306179
5202
+ Added@googlemaps/url-signature@1.0.38(transitive)
+ Addedcrypto-js@4.2.0(transitive)
- Removedcrypto-js@4.1.1
- Removedcrypto-js@4.1.1(transitive)