@sanvika/geolocation 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/index.js +7 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanvika/geolocation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Sanvika ecosystem geolocation SDK — fully centralized via geolocation.sanvikaproduction.com. IP lookup, reverse/forward geocoding, Places autocomplete + details, Maps JS loader. Zero Google API keys in consumer projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/client/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Env vars (read from process.env in Next.js / similar):
|
|
6
6
|
// NEXT_PUBLIC_GEOLOCATION_URL=https://geolocation.sanvikaproduction.com
|
|
7
|
-
//
|
|
7
|
+
// NEXT_PUBLIC_PROJECT_NAME=<slug> (universal, Phase 2 — ecosystem rule §21)
|
|
8
|
+
// (fallback) NEXT_PUBLIC_GEOLOCATION_CLIENT_ID
|
|
8
9
|
//
|
|
9
10
|
// Consumer projects NO LONGER need proxy routes for geolocation.
|
|
10
11
|
// All calls go directly to geolocation.sanvikaproduction.com via public clientId auth.
|
|
11
|
-
// Only getUserLocation / updateUserLocation still need FAPK routes (they use SA SSO auth).
|
|
12
12
|
|
|
13
13
|
import { createLogger } from "@sanvika/logger";
|
|
14
14
|
import { setWithTTL, getWithTTL, TTL } from "./localStorageTTL.js";
|
|
@@ -21,7 +21,11 @@ function _geoUrl() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function _clientId() {
|
|
24
|
-
|
|
24
|
+
// Phase 2 universal first, then legacy fallback (Next.js requires static access)
|
|
25
|
+
if (typeof process === "undefined" || !process.env) return "";
|
|
26
|
+
return process.env.NEXT_PUBLIC_PROJECT_NAME
|
|
27
|
+
|| process.env.NEXT_PUBLIC_GEOLOCATION_CLIENT_ID
|
|
28
|
+
|| "";
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
async function _servicePost(path, body) {
|