@columenlabs/lumen-people 0.1.68 → 0.1.69

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 (2) hide show
  1. package/dist/email.js +13 -0
  2. package/package.json +2 -2
package/dist/email.js CHANGED
@@ -30,6 +30,15 @@ async function call(c, path, init) {
30
30
  return { res: null, ms: Date.now() - t0 };
31
31
  }
32
32
  }
33
+ /** A 3xx: the address leads to a sign-in page (Cloudflare Access, a login proxy), not the API. */
34
+ const redirected = (res) => {
35
+ let to = '';
36
+ try {
37
+ to = new URL(res.headers.get('location') ?? '').host;
38
+ }
39
+ catch { }
40
+ return `The address redirects${to ? ` to ${to}` : ''} (a sign-in page?), not to the email API`;
41
+ };
33
42
  const refused = (status) => status === 401 || status === 403
34
43
  ? 'The server refused the API key'
35
44
  : status === 400 || status === 422
@@ -52,6 +61,8 @@ export async function sendResend(c, msg) {
52
61
  if (!res)
53
62
  return { ok: false, detail: 'Could not reach the email server' };
54
63
  await res.body?.cancel();
64
+ if (res.status >= 300 && res.status < 400)
65
+ return { ok: false, detail: redirected(res) };
55
66
  return res.ok
56
67
  ? { ok: true, detail: `Emailed ${msg.to}` }
57
68
  : { ok: false, detail: refused(res.status) };
@@ -65,6 +76,8 @@ async function reachAndKey(c, where) {
65
76
  return [{ id: 'reach', ok: false, text: `Could not reach ${where}`, ms }];
66
77
  await res.body?.cancel();
67
78
  const reach = { id: 'reach', ok: true, text: `Reached ${where}`, ms };
79
+ if (res.status >= 300 && res.status < 400)
80
+ return [{ ...reach, ok: false, text: redirected(res) }];
68
81
  if (res.status === 404 || res.status === 405)
69
82
  return [{ ...reach, ok: false, text: `${where} has no email API at this address` }];
70
83
  if (res.status === 401 || res.status === 403)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-people",
3
- "version": "0.1.68",
3
+ "version": "0.1.69",
4
4
  "description": "Lumen's people, access and invites on the server: the rules, a SQL store, single-use invite links, a pluggable mailer and the routes the People screens call.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,6 +52,6 @@
52
52
  "registry": "https://registry.npmjs.org/"
53
53
  },
54
54
  "dependencies": {
55
- "@columenlabs/lumen-ui-types": "0.1.68"
55
+ "@columenlabs/lumen-ui-types": "0.1.69"
56
56
  }
57
57
  }