@misiki/gocommerce-connector 0.4.1 → 0.4.3
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/README.md +4 -1
- package/dist/{index-DIj1rK1d.d.cts → index-wGZwLTCe.d.cts} +19 -6
- package/dist/{index-DIj1rK1d.d.ts → index-wGZwLTCe.d.ts} +19 -6
- package/dist/index.cjs +24 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +24 -6
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +24 -7
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/dist/services/index.cjs
CHANGED
|
@@ -214,14 +214,16 @@ var BaseService = class _BaseService {
|
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
216
|
* The store this call is for: the request host's subdomain under
|
|
217
|
-
* `baseDomain`, else the static `store
|
|
218
|
-
*
|
|
219
|
-
*
|
|
217
|
+
* `baseDomain`, else the static `store`, else the host itself when it is a
|
|
218
|
+
* store's own domain (the engine answers only a verified one). Read per call,
|
|
219
|
+
* never stored on the instance, because the server shares one process (and
|
|
220
|
+
* one credentials object) across every concurrent request and each may be
|
|
221
|
+
* for a different host.
|
|
220
222
|
*/
|
|
221
223
|
get store() {
|
|
222
224
|
const { baseDomain, store } = this.creds;
|
|
223
225
|
const host = typeof window !== "undefined" ? window.location?.hostname : requestHost?.();
|
|
224
|
-
return storeForHost(host, baseDomain) ?? store;
|
|
226
|
+
return storeForHost(host, baseDomain) ?? store ?? ownDomain(host, baseDomain);
|
|
225
227
|
}
|
|
226
228
|
/**
|
|
227
229
|
* The engine's base URL from wherever this code runs. In the browser a
|
|
@@ -371,6 +373,14 @@ function storeForHost(host, baseDomain) {
|
|
|
371
373
|
const slug = h.slice(0, -suffix.length);
|
|
372
374
|
return slug && !slug.includes(".") ? slug : void 0;
|
|
373
375
|
}
|
|
376
|
+
function ownDomain(host, baseDomain) {
|
|
377
|
+
if (!host || !baseDomain) return void 0;
|
|
378
|
+
const h = host.toLowerCase().replace(/:\d+$/, "").replace(/\.$/, "");
|
|
379
|
+
const base = baseDomain.toLowerCase().replace(/^\.+/, "").replace(/\.$/, "");
|
|
380
|
+
if (!h.includes(".") || h === base || h.endsWith("." + base) || h.endsWith(".localhost")) return void 0;
|
|
381
|
+
if (/^[\d.]+$/.test(h) || h.includes(":") || h.startsWith("[")) return void 0;
|
|
382
|
+
return h;
|
|
383
|
+
}
|
|
374
384
|
var unreachable = (base, cause) => new GoCommerceError(`Could not reach the commerce engine at ${base}: ${cause?.message ?? cause}`, 0);
|
|
375
385
|
function qs(query) {
|
|
376
386
|
if (!query) return "";
|
|
@@ -988,9 +998,16 @@ var StoreFacts = class extends BaseService {
|
|
|
988
998
|
return false;
|
|
989
999
|
}
|
|
990
1000
|
}
|
|
991
|
-
/**
|
|
1001
|
+
/**
|
|
1002
|
+
* The store's settlement currency and default language, from routes bound
|
|
1003
|
+
* to the store: `/health/ready` answers for the install, so on a shared
|
|
1004
|
+
* engine every store read as the install's currency.
|
|
1005
|
+
*/
|
|
992
1006
|
ready() {
|
|
993
|
-
return remember(this.key("ready"), () =>
|
|
1007
|
+
return remember(this.key("ready"), async () => {
|
|
1008
|
+
const [{ currency }, { language }] = await Promise.all([this.checkoutOptions(), this.profile()]);
|
|
1009
|
+
return { currency, language };
|
|
1010
|
+
});
|
|
994
1011
|
}
|
|
995
1012
|
/** The store's own name and how a buyer reaches it, as set in its panel. */
|
|
996
1013
|
profile() {
|
|
@@ -3187,6 +3204,7 @@ exports.meilisearchService = meilisearchService;
|
|
|
3187
3204
|
exports.menuService = menuService;
|
|
3188
3205
|
exports.newsletterService = newsletterService;
|
|
3189
3206
|
exports.orderService = orderService;
|
|
3207
|
+
exports.ownDomain = ownDomain;
|
|
3190
3208
|
exports.pageService = pageService;
|
|
3191
3209
|
exports.paymentMethodService = paymentMethodService;
|
|
3192
3210
|
exports.pluginService = pluginService;
|