@scalemule/news-publication 0.0.49 → 0.0.51

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.
Files changed (39) hide show
  1. package/README.md +26 -0
  2. package/dist/{chunk-ZXH3O537.js → chunk-ABPJMDUG.js} +1 -1
  3. package/dist/{chunk-MBBPEFDA.js → chunk-AFJ6S5WJ.js} +1 -1
  4. package/dist/{chunk-2MEYHM7M.js → chunk-AMLVCZDP.js} +1 -1
  5. package/dist/{chunk-TTLM7YOH.js → chunk-QW3OZB22.js} +183 -11
  6. package/dist/index.js +3 -3
  7. package/dist/meet-forms.js +2 -2
  8. package/dist/meet-view.d.cts +1 -1
  9. package/dist/meet-view.d.ts +1 -1
  10. package/dist/meet-view.js +2 -2
  11. package/dist/pets-auth-server.cjs +59 -14
  12. package/dist/pets-auth-server.d.cts +7 -1
  13. package/dist/pets-auth-server.d.ts +7 -1
  14. package/dist/pets-auth-server.js +60 -17
  15. package/dist/pets-forms.cjs +8 -4
  16. package/dist/pets-forms.d.cts +4 -2
  17. package/dist/pets-forms.d.ts +4 -2
  18. package/dist/pets-forms.js +10 -6
  19. package/dist/pets-interactions.cjs +6 -5
  20. package/dist/pets-interactions.d.cts +5 -2
  21. package/dist/pets-interactions.d.ts +5 -2
  22. package/dist/pets-interactions.js +7 -6
  23. package/dist/pets-plugin.cjs +551 -0
  24. package/dist/pets-plugin.d.cts +50 -0
  25. package/dist/pets-plugin.d.ts +50 -0
  26. package/dist/pets-plugin.js +317 -0
  27. package/dist/pets-publication.cjs +230 -34
  28. package/dist/pets-publication.d.cts +7 -3
  29. package/dist/pets-publication.d.ts +7 -3
  30. package/dist/pets-publication.js +51 -27
  31. package/dist/pets-server.js +2 -2
  32. package/dist/pets-view.cjs +182 -9
  33. package/dist/pets-view.d.cts +3 -1
  34. package/dist/pets-view.d.ts +3 -1
  35. package/dist/pets-view.js +2 -2
  36. package/dist/pets.cjs +1 -1
  37. package/dist/pets.js +1 -1
  38. package/package.json +6 -1
  39. package/pets.css +215 -7
@@ -1,12 +1,15 @@
1
- import { petPrivateHeaders, petRequest } from './chunk-ZXH3O537.js';
2
- import './chunk-MBBPEFDA.js';
1
+ import { petPrivateHeaders, petRequest } from './chunk-ABPJMDUG.js';
2
+ import './chunk-AFJ6S5WJ.js';
3
3
  import { createHmac, timingSafeEqual, createHash } from 'crypto';
4
4
 
5
5
  var PAW_SESSION_COOKIE = "__Host-paw-reader";
6
- var FLOW = "__Host-paw-signin";
6
+ var PAW_FLOW_COOKIE = "__Host-paw-signin";
7
+ var PAW_SIGNED_OUT_COOKIE = "__Host-paw-signed-out";
8
+ var FLOW = PAW_FLOW_COOKIE;
7
9
  var attrs = "Path=/; HttpOnly; Secure; SameSite=Lax";
8
10
  function pawCookie(request, name = PAW_SESSION_COOKIE) {
9
- return request.headers.get("cookie")?.split(";").map((v) => v.trim()).find((v) => v.startsWith(name + "="))?.slice(name.length + 1);
11
+ const values = (request.headers.get("cookie") || "").split(";").map((v) => v.trim()).filter((v) => v.startsWith(name + "="));
12
+ return values.length === 1 ? values[0].slice(name.length + 1) : void 0;
10
13
  }
11
14
  function digest(value) {
12
15
  return createHash("sha256").update(value).digest("hex");
@@ -55,6 +58,15 @@ function createPawAuthHandler(options) {
55
58
  const scope = await options.resolve(request), origin = new URL(scope.origin).origin;
56
59
  if (!origin.startsWith("https://") || !scope.apiKey)
57
60
  return json({ error: "Sign-in is not configured." }, 503);
61
+ const account = returnPath(options.accountPath || "/account");
62
+ const sessionCookie = options.sessionCookie || PAW_SESSION_COOKIE;
63
+ if (!/^[A-Za-z0-9_-]{1,100}$/.test(sessionCookie))
64
+ throw new Error("Invalid cookie name");
65
+ const retryPath = (path, reason) => {
66
+ const target = new URL(returnPath(path), origin);
67
+ target.searchParams.set("signin", reason);
68
+ return target.pathname + target.search;
69
+ };
58
70
  const redirect = (path) => new Response(null, {
59
71
  status: 303,
60
72
  headers: {
@@ -62,33 +74,60 @@ function createPawAuthHandler(options) {
62
74
  location: origin + returnPath(path)
63
75
  }
64
76
  });
65
- if (action === "start" && request.method === "POST") {
66
- if (request.headers.get("origin") !== origin)
77
+ const resuming = action === "resume" && request.method === "GET";
78
+ if (resuming || action === "start" && request.method === "POST") {
79
+ if (!resuming && request.headers.get("origin") !== origin || resuming && (request.headers.has("sec-fetch-mode") && request.headers.get("sec-fetch-mode") !== "navigate" || request.headers.has("sec-fetch-dest") && request.headers.get("sec-fetch-dest") !== "document"))
67
80
  return json({ error: "Sign in from this website." }, 403);
68
- const callback = origin + "/api/paw-auth/callback";
81
+ const next = returnPath(
82
+ new URL(request.url).searchParams.get("next") || account
83
+ );
84
+ if (resuming && pawCookie(request, PAW_SIGNED_OUT_COOKIE))
85
+ return redirect(retryPath(next, "required"));
86
+ const callback = origin + returnPath(options.callbackPath || "/api/paw-auth/callback");
69
87
  const result = await petRequest(
70
88
  scope,
71
- "/v1/auth/oauth/ledvery/authorize?" + new URLSearchParams({ redirect_uri: callback }),
89
+ "/v1/auth/oauth/ledvery/authorize?" + new URLSearchParams({
90
+ redirect_uri: callback,
91
+ ...resuming ? { prompt: "none" } : {}
92
+ }),
72
93
  {},
73
94
  options.fetch
74
95
  );
75
96
  const url = new URL(result.url);
76
- if (url.origin !== new URL(options.issuerOrigin).origin || url.pathname !== "/authorize" || url.username || url.password || url.searchParams.get("state") !== result.state || url.searchParams.get("redirect_uri") !== callback || url.searchParams.get("code_challenge_method") !== "S256" || !url.searchParams.get("code_challenge"))
97
+ if (url.protocol !== "https:" || url.origin !== new URL(options.issuerOrigin).origin || url.pathname !== "/authorize" || url.username || url.password || url.searchParams.get("state") !== result.state || url.searchParams.get("redirect_uri") !== callback || url.searchParams.get("code_challenge_method") !== "S256" || !url.searchParams.get("code_challenge"))
77
98
  throw new Error("Invalid authorization response");
78
- const response = json({ url: url.href });
99
+ const response = resuming ? new Response(null, {
100
+ status: 303,
101
+ headers: { ...petPrivateHeaders, location: url.href }
102
+ }) : json({ url: url.href });
103
+ if (!resuming)
104
+ response.headers.append(
105
+ "set-cookie",
106
+ `${PAW_SIGNED_OUT_COOKIE}=; ${attrs}; Max-Age=0`
107
+ );
79
108
  response.headers.append(
80
109
  "set-cookie",
81
- `${FLOW}=${sealPawFlow(result.state, returnPath(new URL(request.url).searchParams.get("next")), scope.apiKey)}; ${attrs}; Max-Age=600`
110
+ `${FLOW}=${sealPawFlow(result.state, next, scope.apiKey)}; ${attrs}; Max-Age=600`
82
111
  );
83
112
  return response;
84
113
  }
85
114
  if (action === "callback" && request.method === "GET") {
86
115
  const query = new URL(request.url).searchParams, code = query.get("code"), state = query.get("state");
87
116
  const next = openPawFlow(pawCookie(request, FLOW), state, scope.apiKey);
88
- const response = redirect(next || "/account?signin=retry");
117
+ const response = redirect(next || retryPath(account, "retry"));
89
118
  response.headers.append("set-cookie", `${FLOW}=; ${attrs}; Max-Age=0`);
90
- if (!next || !code || code.length > 4096 || query.has("error"))
119
+ if (!next || !code || code.length > 4096 || query.has("error")) {
120
+ response.headers.set(
121
+ "location",
122
+ origin + retryPath(
123
+ next || account,
124
+ ["login_required", "consent_required"].includes(
125
+ query.get("error") || ""
126
+ ) ? "required" : "retry"
127
+ )
128
+ );
91
129
  return response;
130
+ }
92
131
  try {
93
132
  const session = await petRequest(
94
133
  scope,
@@ -109,11 +148,11 @@ function createPawAuthHandler(options) {
109
148
  throw new Error("Verified reader required");
110
149
  response.headers.append(
111
150
  "set-cookie",
112
- `${PAW_SESSION_COOKIE}=${session.session_token}; ${attrs}; Expires=${new Date(expiry).toUTCString()}`
151
+ `${sessionCookie}=${session.session_token}; ${attrs}; Expires=${new Date(expiry).toUTCString()}`
113
152
  );
114
153
  return response;
115
154
  } catch {
116
- response.headers.set("location", origin + "/account?signin=retry");
155
+ response.headers.set("location", origin + retryPath(next, "retry"));
117
156
  return response;
118
157
  }
119
158
  }
@@ -138,7 +177,11 @@ function createPawAuthHandler(options) {
138
177
  const response = json({ authenticated: false });
139
178
  response.headers.append(
140
179
  "set-cookie",
141
- `${PAW_SESSION_COOKIE}=; ${attrs}; Max-Age=0`
180
+ `${sessionCookie}=; ${attrs}; Max-Age=0`
181
+ );
182
+ response.headers.append(
183
+ "set-cookie",
184
+ `${PAW_SIGNED_OUT_COOKIE}=1; ${attrs}; Max-Age=2592000`
142
185
  );
143
186
  return response;
144
187
  }
@@ -152,4 +195,4 @@ function createPawAuthHandler(options) {
152
195
  };
153
196
  }
154
197
 
155
- export { PAW_SESSION_COOKIE, createPawAuthHandler, openPawFlow, pawCookie, sealPawFlow };
198
+ export { PAW_FLOW_COOKIE, PAW_SESSION_COOKIE, PAW_SIGNED_OUT_COOKIE, createPawAuthHandler, openPawFlow, pawCookie, sealPawFlow };
@@ -120,6 +120,7 @@ function PetSubmissionForm({
120
120
  initial,
121
121
  defaultCommunity,
122
122
  apiPath = "/api/pets",
123
+ accountUrl = "/account",
123
124
  onSaved
124
125
  }) {
125
126
  const [deviceReady, setDeviceReady] = react.useState(false);
@@ -232,7 +233,7 @@ function PetSubmissionForm({
232
233
  /* @__PURE__ */ jsxRuntime.jsx(PawMark, { size: 56 }),
233
234
  /* @__PURE__ */ jsxRuntime.jsx("h1", { children: kind === "profile" && visibility === "private" ? "A little home for your pet." : "Your story is in good hands." }),
234
235
  /* @__PURE__ */ jsxRuntime.jsx("p", { children: kind === "profile" && visibility === "private" ? "Your profile is saved privately. Only you can see it." : "Your contribution is saved for editorial review. It will appear publicly only after approval." }),
235
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/account", children: "View your pets and submissions" })
236
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: accountUrl, children: "View your pets and submissions" })
236
237
  ] });
237
238
  return /* @__PURE__ */ jsxRuntime.jsxs(
238
239
  "form",
@@ -308,7 +309,9 @@ function PetSubmissionForm({
308
309
  source: content.source,
309
310
  event: content.event
310
311
  });
311
- setCommunity(p.area_id);
312
+ setCommunity(
313
+ communities.some((c) => c.id === p.area_id) ? p.area_id : defaultCommunity || ""
314
+ );
312
315
  }
313
316
  },
314
317
  children: [
@@ -727,7 +730,8 @@ function PetSubmissionForm({
727
730
  }
728
731
  function PetOwnerActions({
729
732
  resource,
730
- apiPath = "/api/pets"
733
+ apiPath = "/api/pets",
734
+ submitUrl = "/submit"
731
735
  }) {
732
736
  const [error, setError] = react.useState(""), [confirm, setConfirm] = react.useState(false), [busy, setBusy] = react.useState(false);
733
737
  async function act(action) {
@@ -746,7 +750,7 @@ function PetOwnerActions({
746
750
  }
747
751
  }
748
752
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "paw-form-actions", children: [
749
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: `/submit?edit=${resource.id}`, children: "Edit details or privacy" }),
753
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: `${submitUrl}?edit=${resource.id}`, children: "Edit details or privacy" }),
750
754
  ["lost", "found"].includes(resource.kind) && !resource.reunited_at && /* @__PURE__ */ jsxRuntime.jsx("button", { disabled: busy, onClick: () => void act("reunited"), children: "Mark reunited" }),
751
755
  confirm ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
752
756
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Remove this contribution and its public photographs?" }),
@@ -9,18 +9,20 @@ type Policy = {
9
9
  declare function PetSignIn({ returnTo }: {
10
10
  returnTo?: string;
11
11
  }): React__default.JSX.Element;
12
- declare function PetSubmissionForm({ communities, policy, profiles, initial, defaultCommunity, apiPath, onSaved, }: {
12
+ declare function PetSubmissionForm({ communities, policy, profiles, initial, defaultCommunity, apiPath, accountUrl, onSaved, }: {
13
13
  communities: PetCommunity[];
14
14
  policy: Policy;
15
15
  profiles?: OwnPetResource[];
16
16
  initial?: OwnPetResource;
17
17
  defaultCommunity?: string;
18
18
  apiPath?: string;
19
+ accountUrl?: string;
19
20
  onSaved?: (id: string) => void;
20
21
  }): React__default.JSX.Element;
21
- declare function PetOwnerActions({ resource, apiPath, }: {
22
+ declare function PetOwnerActions({ resource, apiPath, submitUrl, }: {
22
23
  resource: OwnPetResource;
23
24
  apiPath?: string;
25
+ submitUrl?: string;
24
26
  }): React__default.JSX.Element;
25
27
 
26
28
  export { PetOwnerActions, PetSignIn, PetSubmissionForm };
@@ -9,18 +9,20 @@ type Policy = {
9
9
  declare function PetSignIn({ returnTo }: {
10
10
  returnTo?: string;
11
11
  }): React__default.JSX.Element;
12
- declare function PetSubmissionForm({ communities, policy, profiles, initial, defaultCommunity, apiPath, onSaved, }: {
12
+ declare function PetSubmissionForm({ communities, policy, profiles, initial, defaultCommunity, apiPath, accountUrl, onSaved, }: {
13
13
  communities: PetCommunity[];
14
14
  policy: Policy;
15
15
  profiles?: OwnPetResource[];
16
16
  initial?: OwnPetResource;
17
17
  defaultCommunity?: string;
18
18
  apiPath?: string;
19
+ accountUrl?: string;
19
20
  onSaved?: (id: string) => void;
20
21
  }): React__default.JSX.Element;
21
- declare function PetOwnerActions({ resource, apiPath, }: {
22
+ declare function PetOwnerActions({ resource, apiPath, submitUrl, }: {
22
23
  resource: OwnPetResource;
23
24
  apiPath?: string;
25
+ submitUrl?: string;
24
26
  }): React__default.JSX.Element;
25
27
 
26
28
  export { PetOwnerActions, PetSignIn, PetSubmissionForm };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { PawMark } from './chunk-TTLM7YOH.js';
2
+ import { PawMark } from './chunk-QW3OZB22.js';
3
3
  import './chunk-4JRWZXAP.js';
4
4
  import './chunk-66GI2IX6.js';
5
- import { PET_PHOTO_CATEGORIES, PET_CELEBRATIONS, PET_SAFETY } from './chunk-MBBPEFDA.js';
5
+ import { PET_PHOTO_CATEGORIES, PET_CELEBRATIONS, PET_SAFETY } from './chunk-AFJ6S5WJ.js';
6
6
  import { useState, useEffect, useRef } from 'react';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
8
 
@@ -72,6 +72,7 @@ function PetSubmissionForm({
72
72
  initial,
73
73
  defaultCommunity,
74
74
  apiPath = "/api/pets",
75
+ accountUrl = "/account",
75
76
  onSaved
76
77
  }) {
77
78
  const [deviceReady, setDeviceReady] = useState(false);
@@ -184,7 +185,7 @@ function PetSubmissionForm({
184
185
  /* @__PURE__ */ jsx(PawMark, { size: 56 }),
185
186
  /* @__PURE__ */ jsx("h1", { children: kind === "profile" && visibility === "private" ? "A little home for your pet." : "Your story is in good hands." }),
186
187
  /* @__PURE__ */ jsx("p", { children: kind === "profile" && visibility === "private" ? "Your profile is saved privately. Only you can see it." : "Your contribution is saved for editorial review. It will appear publicly only after approval." }),
187
- /* @__PURE__ */ jsx("a", { href: "/account", children: "View your pets and submissions" })
188
+ /* @__PURE__ */ jsx("a", { href: accountUrl, children: "View your pets and submissions" })
188
189
  ] });
189
190
  return /* @__PURE__ */ jsxs(
190
191
  "form",
@@ -260,7 +261,9 @@ function PetSubmissionForm({
260
261
  source: content.source,
261
262
  event: content.event
262
263
  });
263
- setCommunity(p.area_id);
264
+ setCommunity(
265
+ communities.some((c) => c.id === p.area_id) ? p.area_id : defaultCommunity || ""
266
+ );
264
267
  }
265
268
  },
266
269
  children: [
@@ -679,7 +682,8 @@ function PetSubmissionForm({
679
682
  }
680
683
  function PetOwnerActions({
681
684
  resource,
682
- apiPath = "/api/pets"
685
+ apiPath = "/api/pets",
686
+ submitUrl = "/submit"
683
687
  }) {
684
688
  const [error, setError] = useState(""), [confirm, setConfirm] = useState(false), [busy, setBusy] = useState(false);
685
689
  async function act(action) {
@@ -698,7 +702,7 @@ function PetOwnerActions({
698
702
  }
699
703
  }
700
704
  return /* @__PURE__ */ jsxs("div", { className: "paw-form-actions", children: [
701
- /* @__PURE__ */ jsx("a", { href: `/submit?edit=${resource.id}`, children: "Edit details or privacy" }),
705
+ /* @__PURE__ */ jsx("a", { href: `${submitUrl}?edit=${resource.id}`, children: "Edit details or privacy" }),
702
706
  ["lost", "found"].includes(resource.kind) && !resource.reunited_at && /* @__PURE__ */ jsx("button", { disabled: busy, onClick: () => void act("reunited"), children: "Mark reunited" }),
703
707
  confirm ? /* @__PURE__ */ jsxs(Fragment, { children: [
704
708
  /* @__PURE__ */ jsx("span", { children: "Remove this contribution and its public photographs?" }),
@@ -27,7 +27,7 @@ async function request(path, method = "GET", body) {
27
27
  );
28
28
  return value.data ?? value;
29
29
  }
30
- function PetSignOut() {
30
+ function PetSignOut({ returnTo = "/" }) {
31
31
  const [error, setError] = react.useState("");
32
32
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
33
33
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -36,12 +36,12 @@ function PetSignOut() {
36
36
  onClick: async () => {
37
37
  try {
38
38
  await request("/api/paw-auth/logout", "POST");
39
- window.location.assign("/");
39
+ window.location.assign(returnTo);
40
40
  } catch {
41
41
  setError("Sign-out could not be completed. Please try again.");
42
42
  }
43
43
  },
44
- children: "Sign out"
44
+ children: "Sign out of this site"
45
45
  }
46
46
  ),
47
47
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: error })
@@ -196,7 +196,8 @@ function PetPreferencesForm({
196
196
  function PetResourceActions({
197
197
  resource,
198
198
  signedIn,
199
- apiPath = "/api/pets"
199
+ apiPath = "/api/pets",
200
+ accountUrl = "/account"
200
201
  }) {
201
202
  const [active, setActive] = react.useState(false), [reporting, setReporting] = react.useState(false), [message, setMessage] = react.useState(""), [busy, setBusy] = react.useState(false);
202
203
  const reportKey = react.useRef("");
@@ -318,7 +319,7 @@ function PetResourceActions({
318
319
  ) : /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(
319
320
  "a",
320
321
  {
321
- href: "/account?next=" + encodeURIComponent(`/pets/${resource.id}`),
322
+ href: accountUrl + "?next=" + encodeURIComponent(`/pets/${resource.id}`),
322
323
  children: "Sign in to send a private report."
323
324
  }
324
325
  ) })),
@@ -1,7 +1,9 @@
1
1
  import React__default from 'react';
2
2
  import { PetPreferenceRecord, PetCommunity, PetResource } from './pets.cjs';
3
3
 
4
- declare function PetSignOut(): React__default.JSX.Element;
4
+ declare function PetSignOut({ returnTo }: {
5
+ returnTo?: string;
6
+ }): React__default.JSX.Element;
5
7
  declare function PetCommunityMemory({ selected, signedIn, }: {
6
8
  selected?: string | null;
7
9
  signedIn: boolean;
@@ -11,10 +13,11 @@ declare function PetPreferencesForm({ record, communities, notificationsReady, }
11
13
  communities: PetCommunity[];
12
14
  notificationsReady?: boolean;
13
15
  }): React__default.JSX.Element;
14
- declare function PetResourceActions({ resource, signedIn, apiPath, }: {
16
+ declare function PetResourceActions({ resource, signedIn, apiPath, accountUrl, }: {
15
17
  resource: PetResource;
16
18
  signedIn: boolean;
17
19
  apiPath?: string;
20
+ accountUrl?: string;
18
21
  }): React__default.JSX.Element;
19
22
 
20
23
  export { PetCommunityMemory, PetPreferencesForm, PetResourceActions, PetSignOut };
@@ -1,7 +1,9 @@
1
1
  import React__default from 'react';
2
2
  import { PetPreferenceRecord, PetCommunity, PetResource } from './pets.js';
3
3
 
4
- declare function PetSignOut(): React__default.JSX.Element;
4
+ declare function PetSignOut({ returnTo }: {
5
+ returnTo?: string;
6
+ }): React__default.JSX.Element;
5
7
  declare function PetCommunityMemory({ selected, signedIn, }: {
6
8
  selected?: string | null;
7
9
  signedIn: boolean;
@@ -11,10 +13,11 @@ declare function PetPreferencesForm({ record, communities, notificationsReady, }
11
13
  communities: PetCommunity[];
12
14
  notificationsReady?: boolean;
13
15
  }): React__default.JSX.Element;
14
- declare function PetResourceActions({ resource, signedIn, apiPath, }: {
16
+ declare function PetResourceActions({ resource, signedIn, apiPath, accountUrl, }: {
15
17
  resource: PetResource;
16
18
  signedIn: boolean;
17
19
  apiPath?: string;
20
+ accountUrl?: string;
18
21
  }): React__default.JSX.Element;
19
22
 
20
23
  export { PetCommunityMemory, PetPreferencesForm, PetResourceActions, PetSignOut };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { PET_NOTIFICATION_CATEGORIES } from './chunk-MBBPEFDA.js';
2
+ import { PET_NOTIFICATION_CATEGORIES } from './chunk-AFJ6S5WJ.js';
3
3
  import { useState, useEffect, useRef } from 'react';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
@@ -17,7 +17,7 @@ async function request(path, method = "GET", body) {
17
17
  );
18
18
  return value.data ?? value;
19
19
  }
20
- function PetSignOut() {
20
+ function PetSignOut({ returnTo = "/" }) {
21
21
  const [error, setError] = useState("");
22
22
  return /* @__PURE__ */ jsxs("div", { children: [
23
23
  /* @__PURE__ */ jsx(
@@ -26,12 +26,12 @@ function PetSignOut() {
26
26
  onClick: async () => {
27
27
  try {
28
28
  await request("/api/paw-auth/logout", "POST");
29
- window.location.assign("/");
29
+ window.location.assign(returnTo);
30
30
  } catch {
31
31
  setError("Sign-out could not be completed. Please try again.");
32
32
  }
33
33
  },
34
- children: "Sign out"
34
+ children: "Sign out of this site"
35
35
  }
36
36
  ),
37
37
  error && /* @__PURE__ */ jsx("p", { role: "alert", children: error })
@@ -186,7 +186,8 @@ function PetPreferencesForm({
186
186
  function PetResourceActions({
187
187
  resource,
188
188
  signedIn,
189
- apiPath = "/api/pets"
189
+ apiPath = "/api/pets",
190
+ accountUrl = "/account"
190
191
  }) {
191
192
  const [active, setActive] = useState(false), [reporting, setReporting] = useState(false), [message, setMessage] = useState(""), [busy, setBusy] = useState(false);
192
193
  const reportKey = useRef("");
@@ -308,7 +309,7 @@ function PetResourceActions({
308
309
  ) : /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(
309
310
  "a",
310
311
  {
311
- href: "/account?next=" + encodeURIComponent(`/pets/${resource.id}`),
312
+ href: accountUrl + "?next=" + encodeURIComponent(`/pets/${resource.id}`),
312
313
  children: "Sign in to send a private report."
313
314
  }
314
315
  ) })),