@porulle/plugin-channel-connector 0.74.0 → 0.74.1

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/dist/index.js CHANGED
@@ -399,7 +399,18 @@ export function channelConnectorPlugin(options = {}) {
399
399
  if (!userId)
400
400
  return oauthError(403, "USER_REQUIRED", "Connecting a store needs a signed-in user.");
401
401
  const typed = String(query.shop ?? query.store ?? "");
402
- const storeDomain = connector.normalizeStoreDomain ? connector.normalizeStoreDomain(typed) : typed;
402
+ // A connector that can look at the store first does, so the merchant is told what is wrong
403
+ // here rather than landing on a broken page at their own site.
404
+ let storeDomain;
405
+ if (connector.probeStore) {
406
+ const probed = await connector.probeStore(typed);
407
+ if (!probed.ok)
408
+ return connectOutcome(oauth.postConnectRedirect, { error: probed.error.code, message: probed.error.message });
409
+ storeDomain = probed.value.storeDomain;
410
+ }
411
+ else {
412
+ storeDomain = connector.normalizeStoreDomain ? connector.normalizeStoreDomain(typed) : typed;
413
+ }
403
414
  if (!storeDomain)
404
415
  return connectOutcome(oauth.postConnectRedirect, { error: "INVALID_STORE_DOMAIN", message: `"${typed}" does not name a ${provider} store.` });
405
416
  // Refused HERE, before the merchant reaches the provider: a grant issued for a shop retires
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/plugin-channel-connector",
3
- "version": "0.74.0",
3
+ "version": "0.74.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,15 +22,15 @@
22
22
  "dependencies": {
23
23
  "@hono/zod-openapi": "^1.2.2",
24
24
  "hono": "^4.12.5",
25
- "@porulle/core": "0.74.0"
25
+ "@porulle/core": "0.74.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^24.5.2",
29
29
  "eslint": "^9.39.1",
30
30
  "typescript": "5.9.2",
31
31
  "vitest": "^3.2.4",
32
- "@porulle/eslint-config": "0.1.0",
33
- "@porulle/typescript-config": "0.1.0"
32
+ "@porulle/typescript-config": "0.1.0",
33
+ "@porulle/eslint-config": "0.1.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
package/src/index.ts CHANGED
@@ -572,7 +572,16 @@ export function channelConnectorPlugin(options: ChannelConnectorPluginOptions =
572
572
  const userId = actor?.userId;
573
573
  if (!userId) return oauthError(403, "USER_REQUIRED", "Connecting a store needs a signed-in user.");
574
574
  const typed = String((query as { shop?: string; store?: string }).shop ?? (query as { store?: string }).store ?? "");
575
- const storeDomain = connector.normalizeStoreDomain ? connector.normalizeStoreDomain(typed) : typed;
575
+ // A connector that can look at the store first does, so the merchant is told what is wrong
576
+ // here rather than landing on a broken page at their own site.
577
+ let storeDomain: string | undefined;
578
+ if (connector.probeStore) {
579
+ const probed = await connector.probeStore(typed);
580
+ if (!probed.ok) return connectOutcome(oauth.postConnectRedirect, { error: probed.error.code, message: probed.error.message });
581
+ storeDomain = probed.value.storeDomain;
582
+ } else {
583
+ storeDomain = connector.normalizeStoreDomain ? connector.normalizeStoreDomain(typed) : typed;
584
+ }
576
585
  if (!storeDomain) return connectOutcome(oauth.postConnectRedirect, { error: "INVALID_STORE_DOMAIN", message: `"${typed}" does not name a ${provider} store.` });
577
586
  // Refused HERE, before the merchant reaches the provider: a grant issued for a shop retires
578
587
  // that shop's other grants, so a refusal at the callback would already have broken them.