@axiumine/koa-utils 7.1.0 → 7.2.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.
Files changed (87) hide show
  1. package/LICENSE +0 -5
  2. package/README.md +55 -3
  3. package/dist/dataSources/MariaDB.mjs +8 -6
  4. package/dist/dataSources/MongoDB.mjs +1 -1
  5. package/dist/dataSources/PostgreSQL.mjs +12 -12
  6. package/dist/dataSources/Redis.mjs +8 -7
  7. package/dist/email/SocketLabsLib.d.mts +6 -15
  8. package/dist/email/SocketLabsLib.mjs +54 -210
  9. package/dist/files/moveFileStaticDomain.mjs +1 -1
  10. package/dist/files/storeUploadAsTemp.mjs +5 -1
  11. package/dist/files/uploadTempImage.mjs +2 -1
  12. package/dist/files/uploadTempPdf.mjs +2 -1
  13. package/dist/graphQL/models/MongoDB/UserBase.d.mts +3 -1
  14. package/dist/graphQL/models/MongoDB/log/DevStatsGraphQLCalls.d.mts +3 -1
  15. package/dist/graphQL/models/MongoDB/log/LogGlobalError.d.mts +3 -1
  16. package/dist/graphQL/models/MongoDB/log/LogStatsGraphql.d.mts +3 -1
  17. package/dist/graphQL/models/MongoDB/log/LogThrow.d.mts +3 -1
  18. package/dist/graphQL/schema/mutations/emailChangeHashVerify.mjs +8 -76
  19. package/dist/graphQL/schema/mutations/login4Ever.mjs +1 -0
  20. package/dist/graphQL/schema/mutations/loginAdmin.mjs +1 -0
  21. package/dist/graphQL/schema/mutations/loginRememberme.mjs +1 -0
  22. package/dist/graphQL/schema/mutations/logout.mjs +2 -2
  23. package/dist/graphQL/schema/mutations/refresh.mjs +7 -5
  24. package/dist/graphQL/schema/mutations/resetPwd.d.mts +1 -1
  25. package/dist/graphQL/schema/mutations/signUp.mjs +1 -0
  26. package/dist/graphQL/schema/mutations/updatePassword.mjs +1 -48
  27. package/dist/koa/middleware/authenticatedAuthorizationHandler/index.mjs +2 -2
  28. package/dist/koa/middleware/authenticatedAuthorizationHandler/verifySignedRefreshToken.mjs +2 -0
  29. package/dist/koa/middleware/authenticatedLogoutHandler/index.mjs +2 -2
  30. package/dist/koa/middleware/authenticatedResourceHandler/index.mjs +2 -2
  31. package/dist/koa/tdwKoaErrorHandler.mjs +1 -1
  32. package/dist/lib/ArrayLib.mjs +4 -3
  33. package/dist/lib/DateLib.mjs +1 -0
  34. package/dist/lib/StringLib.mjs +56 -4
  35. package/dist/lib/access/resetPwdMailer.d.mts +3 -0
  36. package/dist/lib/access/resetPwdMailer.mjs +3 -0
  37. package/dist/lib/db/log/hitStat.mjs +1 -0
  38. package/dist/lib/isIntrospectionBypassAllowed.mjs +1 -1
  39. package/dist/lib/isSessionBlocked.mjs +1 -1
  40. package/dist/lib/tokens.mjs +2 -1
  41. package/dist/lib/tryCatchRethrow.mjs +1 -1
  42. package/dist/private/dataSources/isRedisTlsRequired.mjs +1 -1
  43. package/dist/private/email/IEmailContent.d.mts +9 -0
  44. package/dist/private/email/IEmailContent.mjs +2 -0
  45. package/dist/private/email/accountMessages.d.mts +11 -0
  46. package/dist/private/email/accountMessages.mjs +57 -0
  47. package/dist/private/email/escapeHtml.d.mts +9 -0
  48. package/dist/private/email/escapeHtml.mjs +17 -0
  49. package/dist/private/email/htmlFrame.d.mts +10 -0
  50. package/dist/private/email/htmlFrame.mjs +25 -0
  51. package/dist/private/email/messageParts.d.mts +21 -0
  52. package/dist/private/email/messageParts.mjs +65 -0
  53. package/dist/private/email/noticeMessages.d.mts +14 -0
  54. package/dist/private/email/noticeMessages.mjs +51 -0
  55. package/dist/private/email/orFalse.d.mts +2 -0
  56. package/dist/private/email/orFalse.mjs +12 -0
  57. package/dist/private/email/resetMessages.d.mts +17 -0
  58. package/dist/private/email/resetMessages.mjs +46 -0
  59. package/dist/private/graphQL/models/MongoDB/private/UserAdminKoaUtils.d.mts +4 -2
  60. package/dist/private/graphQL/schema/mutations/_buildLoginStatsUpdate.mjs +4 -4
  61. package/dist/private/graphQL/schema/mutations/infoUserForLoginSQL.mjs +5 -4
  62. package/dist/private/graphQL/schema/mutations/setRedisLoginSession.mjs +2 -2
  63. package/dist/private/graphQL/schema/mutations/updateLoginStats4ever.mjs +2 -2
  64. package/dist/private/lib/access/applyPasswordReset.d.mts +22 -0
  65. package/dist/private/lib/access/applyPasswordReset.mjs +22 -0
  66. package/dist/private/lib/access/assertResetAllowed.d.mts +14 -0
  67. package/dist/private/lib/access/assertResetAllowed.mjs +51 -0
  68. package/dist/private/lib/access/assertVerifyEmailAllowed.d.mts +6 -1
  69. package/dist/private/lib/access/db/abandonUser.mjs +3 -0
  70. package/dist/private/lib/access/db/confirmNewEmail.mjs +2 -0
  71. package/dist/private/lib/access/db/deleteUserByEmail.mjs +2 -0
  72. package/dist/private/lib/access/db/enableEmailAccess.mjs +9 -1
  73. package/dist/private/lib/access/db/getResetPwd.mjs +2 -0
  74. package/dist/private/lib/access/db/removeResetReq.mjs +2 -0
  75. package/dist/private/lib/access/db/saveResetReq.mjs +2 -0
  76. package/dist/private/lib/access/db/setEmailHash.mjs +2 -0
  77. package/dist/private/lib/access/db/updatePasswordDb.mjs +2 -0
  78. package/dist/private/lib/access/db/userData4VerifyEmail.mjs +2 -0
  79. package/dist/private/lib/access/emailChangeHandlers.d.mts +35 -0
  80. package/dist/private/lib/access/emailChangeHandlers.mjs +87 -0
  81. package/dist/private/lib/access/handleIfHashBad.d.mts +4 -2
  82. package/dist/private/lib/access/handleIfHashBad.mjs +4 -1
  83. package/dist/private/lib/access/safeEqualSecret.d.mts +13 -0
  84. package/dist/private/lib/access/safeEqualSecret.mjs +26 -0
  85. package/dist/private/lib/verifyIntrospectionCode.d.mts +4 -0
  86. package/dist/private/lib/verifyIntrospectionCode.mjs +8 -14
  87. package/package.json +62 -25
package/LICENSE CHANGED
@@ -1,8 +1,3 @@
1
- koa-utils — Koa utility package
2
- Copyright (C) 2026 Giovanni Manzoni
3
-
4
-
5
-
6
1
  GNU GENERAL PUBLIC LICENSE
7
2
  Version 3, 29 June 2007
8
3
  Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @axiumine/koa-utils
2
2
 
3
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/Axiumine/koa-utils/badge)](https://scorecard.dev/viewer/?uri=github.com/Axiumine/koa-utils)
4
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/16094/badge)](https://www.bestpractices.dev/projects/16094)
5
+
3
6
  TypeScript utility library for Koa + GraphQL backends. Ships authentication middleware, GraphQL error helpers, data-source connectors (MongoDB, MariaDB, PostgreSQL, Redis), file upload pipeline (ClamAV + sharp re-encode), and transactional email via SocketLabs.
4
7
 
5
8
  - **Module format:** ESM only (`.mjs` + `.d.mts`)
@@ -7,6 +10,7 @@ TypeScript utility library for Koa + GraphQL backends. Ships authentication midd
7
10
  - **TypeScript:** `6.0`
8
11
  - **License:** GPL-3.0-or-later
9
12
  - **Maintainer:** [Giovanni Manzoni](https://www.giovannimanzoni.com)
13
+ - **Project:** [Contributing](https://github.com/Axiumine/koa-utils/blob/main/CONTRIBUTING.md) · [Governance](https://github.com/Axiumine/koa-utils/blob/main/GOVERNANCE.md) · [Roadmap](https://github.com/Axiumine/koa-utils/blob/main/ROADMAP.md) · [Security policy](https://github.com/Axiumine/koa-utils/blob/main/SECURITY.md) · [Code of Conduct](https://github.com/Axiumine/koa-utils/blob/main/CODE_OF_CONDUCT.md) · [Changelog](https://github.com/Axiumine/koa-utils/blob/main/CHANGELOG.md)
10
14
 
11
15
  ## Install
12
16
 
@@ -43,6 +47,39 @@ The remaining twelve are declared **optional** in `peerDependenciesMeta`. There
43
47
 
44
48
  Optionality is a promise about the load path, not a way to silence the warning: it holds only while the dependency stays behind a subpath the consumer opts into. Adding a root `"."` barrel, or importing one of these from a module that every subpath reaches, breaks it for every consumer at once.
45
49
 
50
+ ## Quick start
51
+
52
+ A Koa app that refuses every request without a valid access token and answers with the caller's id. It needs a MongoDB and a Redis server you can reach.
53
+
54
+ ```bash
55
+ yarn add @axiumine/koa-utils @node-rs/bcrypt @sentry/node dotenv graphql mongoose redis uuid koa
56
+ printf 'MONGODB_URI=mongodb://localhost:27017/app\nREDIS_URL=redis://localhost:6379\nREDIS_KEY=app:\n' > .env
57
+ ```
58
+
59
+ Save this as `server.mts`:
60
+
61
+ ```ts
62
+ import 'dotenv/config'
63
+ import Koa from 'koa'
64
+ import { MongoDBConnect } from '@axiumine/koa-utils/dataSources/MongoDB'
65
+ import { RedisConnect } from '@axiumine/koa-utils/dataSources/Redis'
66
+ import { tdwKoaErrorHandler } from '@axiumine/koa-utils/koa/tdwKoaErrorHandler'
67
+ import { authenticatedResourceHandler } from '@axiumine/koa-utils/koa/middleware/authenticatedResourceHandler'
68
+
69
+ await MongoDBConnect()
70
+ await RedisConnect()
71
+
72
+ const app = new Koa()
73
+ app.use(tdwKoaErrorHandler)
74
+ app.use(authenticatedResourceHandler())
75
+ app.use(async (ctx) => {
76
+ ctx.body = { userId: String(ctx.state.user.id) }
77
+ })
78
+ app.listen(3000)
79
+ ```
80
+
81
+ Run it with `node server.mts` (an ES module project, `"type": "module"`, Node `^24.14.0`, which strips the types itself). `curl -i localhost:3000` answers `412 Precondition Failed` ("No authorization header."): a request needs `Authorization: Bearer access:<uuid>` with a token that exists in Redis. To obtain one, add the `signUp` and `loginRememberme` mutations from [Usage](#usage) to your GraphQL schema and follow the [Auth flow](#auth-flow).
82
+
46
83
  ## Usage
47
84
 
48
85
  No barrel — import each helper from its explicit subpath.
@@ -69,7 +106,10 @@ import { authenticatedResourceHandler } from '@axiumine/koa-utils/koa/middleware
69
106
  import { authenticatedAuthorizationHandler } from '@axiumine/koa-utils/koa/middleware/authenticatedAuthorizationHandler'
70
107
 
71
108
  const app = new Koa()
72
- const keys = new Keygrip([process.env.COOKIE_KEY!])
109
+ // Keygrip signs with HMAC-SHA1 unless told otherwise: pass 'sha256'.
110
+ // Koa signs the refresh cookie with app.keys, so verify with that same instance.
111
+ const keys = new Keygrip([process.env.COOKIE_KEY!], 'sha256')
112
+ app.keys = keys
73
113
 
74
114
  app.use(tdwKoaErrorHandler)
75
115
  app.use(authenticatedResourceHandler()) // resource endpoints
@@ -126,7 +166,7 @@ const verify = createVerifyEmailFlow({
126
166
  router.get('/check/verify-email/:email/:hash', verify.routerVerifyEmail())
127
167
  ```
128
168
 
129
- Every `paths` key is optional and falls back to the `UserBase` layout, so the package-level exports are exactly these factories with no overrides. See [docs/code/lib-access.md](./docs/code/lib-access.md).
169
+ Every `paths` key is optional and falls back to the `UserBase` layout, so the package-level exports are exactly these factories with no overrides. See [docs/code/lib-access.md](https://github.com/Axiumine/koa-utils/blob/main/docs/code/lib-access.md).
130
170
 
131
171
  `onAbandon` decides what the two disposal guards — the fifth wrong hash and a link older than 3 days — do to a pending registration. The default `'delete'` removes the row; use `'soft-delete'` or `'keep'` when other collections depend on it, since mongo has no cascade, or pass `deleteUserByEmail` to replace the writer outright. The link is rejected either way.
132
172
 
@@ -257,8 +297,12 @@ For the cluster path the `rediss://` scheme on `rootNodes` is not enough on its
257
297
  ```bash
258
298
  yarn install
259
299
  yarn build # ESM only — production output
260
- yarn build:all # ESM + CJS dual output
300
+ yarn build:all # not usable today: the CJS half emits nothing, the package is ESM-only (use yarn build)
301
+ yarn test # build + build:tests + mocha, no coverage gate
302
+ yarn test:coverage # same under c8: fails below 100% on lines, statements, functions or branches of any file
261
303
  yarn lint # eslint --fix + prettier --write
304
+ yarn lint:check # eslint + prettier --check, writes nothing
305
+ yarn check:static # every static gate: caps, lint, typecheck (src, scripts, specs), knip, type-coverage, fta (runs in CI)
262
306
  yarn clean
263
307
  ```
264
308
 
@@ -276,6 +320,14 @@ There is no barrel and no `main` / `module` field.
276
320
 
277
321
  Maintainers who install through a private npm mirror should not commit its host: a git clean/smudge filter rewrites the `resolved` URLs in both directions, keeping the mirror in the working copy and the public registry in history. `yarn install` configures it (via `prepare` → `hooks:install`); point it at your own mirror with `YARN_PROXY_REGISTRY`. A pre-commit check rejects any lockfile that still names a non-public host.
278
322
 
323
+ ## Feedback, contributing and security
324
+
325
+ - **Bugs and feature requests:** open an issue at <https://github.com/Axiumine/koa-utils/issues/new/choose>. Issues are public and searchable.
326
+ - **Contributing code:** fork, branch from `main` and open a pull request; larger changes start with an issue. [CONTRIBUTING.md](https://github.com/Axiumine/koa-utils/blob/main/CONTRIBUTING.md) lists the requirements (tests at 100% coverage, docs in the same change, Conventional Commits, GPL-3.0-or-later). How decisions are made is in [GOVERNANCE.md](https://github.com/Axiumine/koa-utils/blob/main/GOVERNANCE.md); the direction is in [ROADMAP.md](https://github.com/Axiumine/koa-utils/blob/main/ROADMAP.md).
327
+ - **Security vulnerabilities:** never in a public issue. Use GitHub private vulnerability reporting or the email in [SECURITY.md](https://github.com/Axiumine/koa-utils/blob/main/SECURITY.md), which also states the supported versions and response times.
328
+ - **Security model and design:** what the library does and does not protect against is in [docs/security.md](https://github.com/Axiumine/koa-utils/blob/main/docs/security.md); the structure is in [docs/architecture.md](https://github.com/Axiumine/koa-utils/blob/main/docs/architecture.md). How to check a release (signed tag, rebuild, attestation) is in [docs/verify-release.md](https://github.com/Axiumine/koa-utils/blob/main/docs/verify-release.md).
329
+ - **Release notes:** [CHANGELOG.md](https://github.com/Axiumine/koa-utils/blob/main/CHANGELOG.md), one entry per release, with a `Security` section whenever a release fixes a vulnerability.
330
+
279
331
  ## Repository
280
332
 
281
333
  <https://github.com/Axiumine/koa-utils>
@@ -2,8 +2,8 @@ import * as Sentry from '@sentry/node';
2
2
  import * as dotenv from 'dotenv';
3
3
  import { Sequelize } from 'sequelize-typescript';
4
4
  dotenv.config();
5
- export const sequelize = new Sequelize(`${process.env.MARIADB_DBNAME}`, `${process.env.MARIADB_USER}`, `${process.env.MARIADB_PWD}`, {
6
- host: `${process.env.MARIADB_IP}`,
5
+ export const sequelize = new Sequelize(`${process.env['MARIADB_DBNAME']}`, `${process.env['MARIADB_USER']}`, `${process.env['MARIADB_PWD']}`, {
6
+ host: `${process.env['MARIADB_IP']}`,
7
7
  dialect: 'mariadb',
8
8
  query: { raw: true },
9
9
  pool: {
@@ -24,17 +24,19 @@ export const sequelize = new Sequelize(`${process.env.MARIADB_DBNAME}`, `${proce
24
24
  backoffExponent: 1.1,
25
25
  timeout: 3000,
26
26
  backoffJitter: 0.1, // Add this required property
27
- max: parseInt(`${process.env.MARIADB_RETRY}`) || 5
27
+ max: parseInt(`${process.env['MARIADB_RETRY']}`) || 5
28
28
  },
29
29
  dialectOptions: {
30
30
  useUTC: true,
31
31
  skipSetTimezone: true,
32
32
  compress: true,
33
- requestTimeout: parseInt(`${process.env.MARIADB_TIMEOUT}`) || 5000
33
+ requestTimeout: parseInt(`${process.env['MARIADB_TIMEOUT']}`) || 5000
34
34
  },
35
- port: parseInt(`${process.env.MARIADB_PORT}`, 10),
35
+ port: parseInt(`${process.env['MARIADB_PORT']}`, 10),
36
+ // Explicit `undefined` is load-bearing: Sequelize reads the key with hasOwnProperty, so omitting it would switch
37
+ // query logging on. The cast only satisfies exactOptionalPropertyTypes (tsconfig.check.json); runtime is unchanged.
36
38
  /* c8 ignore next -- env-dependent boot config; covered only when MARIADB_LOGGING='false' */
37
- logging: process.env.MARIADB_LOGGING === 'false' ? false : undefined // disable print queries in console
39
+ logging: (process.env['MARIADB_LOGGING'] === 'false' ? false : undefined) // disable print queries in console
38
40
  });
39
41
  // Setting up a connection
40
42
  export const MariaDBConnect = async () => {
@@ -24,7 +24,7 @@ export async function MongoDBConnect() {
24
24
  };
25
25
  mongoose.set('sanitizeFilter', true);
26
26
  mongoose.set('strictQuery', false); // will be done in mongose 7
27
- await mongoose.connect(`${process.env.MONGODB_URI}`, options);
27
+ await mongoose.connect(`${process.env['MONGODB_URI']}`, options);
28
28
  /* c8 ignore next 2 -- success log + closing brace; covered only with live MongoDB */
29
29
  console.info('[MongoDB] OK: MongoDB connection has been established successfully. ');
30
30
  }
@@ -4,20 +4,20 @@ import pg from 'pg';
4
4
  const { Client, Pool } = pg;
5
5
  dotenv.config();
6
6
  export const pgClient = new Client({
7
- user: `${process.env.POSTGRESQL_USER}`,
8
- password: `${process.env.POSTGRESQL_PWD}`,
9
- host: `${process.env.POSTGRESQL_HOST}`,
10
- port: parseInt(`${process.env.POSTGRESQL_PORT}`, 10),
11
- database: `${process.env.POSTGRESQL_DBNAME}`
7
+ user: `${process.env['POSTGRESQL_USER']}`,
8
+ password: `${process.env['POSTGRESQL_PWD']}`,
9
+ host: `${process.env['POSTGRESQL_HOST']}`,
10
+ port: parseInt(`${process.env['POSTGRESQL_PORT']}`, 10),
11
+ database: `${process.env['POSTGRESQL_DBNAME']}`
12
12
  });
13
13
  export const pgPool = new Pool({
14
- user: `${process.env.POSTGRESQL_USER}`,
15
- password: `${process.env.POSTGRESQL_PWD}`,
16
- host: `${process.env.POSTGRESQL_HOST}`,
17
- port: parseInt(`${process.env.POSTGRESQL_PORT}`, 10),
18
- database: `${process.env.POSTGRESQL_DBNAME}`,
19
- max: parseInt(`${process.env.POSTGRESQL_POOL_MAX}`, 10),
20
- idleTimeoutMillis: parseInt(`${process.env.POSTGRESQL_IDLE_TIMEOUT}`, 10)
14
+ user: `${process.env['POSTGRESQL_USER']}`,
15
+ password: `${process.env['POSTGRESQL_PWD']}`,
16
+ host: `${process.env['POSTGRESQL_HOST']}`,
17
+ port: parseInt(`${process.env['POSTGRESQL_PORT']}`, 10),
18
+ database: `${process.env['POSTGRESQL_DBNAME']}`,
19
+ max: parseInt(`${process.env['POSTGRESQL_POOL_MAX']}`, 10),
20
+ idleTimeoutMillis: parseInt(`${process.env['POSTGRESQL_IDLE_TIMEOUT']}`, 10)
21
21
  });
22
22
  // the pool will emit an error on behalf of any idle clients
23
23
  // it contains if a backend error or network partition happens
@@ -5,17 +5,18 @@ import * as Sentry from '@sentry/node';
5
5
  import * as dotenv from 'dotenv';
6
6
  import { createClient, createCluster } from 'redis';
7
7
  dotenv.config();
8
- export const redisClient = process.env.REDIS_IS_CLUSTER === '1'
8
+ export const redisClient = process.env['REDIS_IS_CLUSTER'] === '1'
9
9
  ? /* c8 ignore start -- cluster branch: requires REDIS_IS_CLUSTER=1 + 3 redis nodes, not in unit env */
10
10
  createCluster({
11
11
  rootNodes: [
12
- { url: redisNodeUrl(process.env.REDIS_DB1_HOST, process.env.REDIS_DB1_PORT) },
13
- { url: redisNodeUrl(process.env.REDIS_DB2_HOST, process.env.REDIS_DB2_PORT) },
14
- { url: redisNodeUrl(process.env.REDIS_DB3_HOST, process.env.REDIS_DB3_PORT) }
12
+ { url: redisNodeUrl(process.env['REDIS_DB1_HOST'], process.env['REDIS_DB1_PORT']) },
13
+ { url: redisNodeUrl(process.env['REDIS_DB2_HOST'], process.env['REDIS_DB2_PORT']) },
14
+ { url: redisNodeUrl(process.env['REDIS_DB3_HOST'], process.env['REDIS_DB3_PORT']) }
15
15
  ],
16
16
  defaults: {
17
- username: process.env.REDIS_USERNAME,
18
- password: process.env.REDIS_PASSWORD,
17
+ // casts only satisfy exactOptionalPropertyTypes (tsconfig.check.json); an unset var still reaches node-redis as undefined
18
+ username: process.env['REDIS_USERNAME'],
19
+ password: process.env['REDIS_PASSWORD'],
19
20
  // rootNodes only carry the topology-discovery connections; node-redis does not inherit their
20
21
  // TLS setting for the connections it then opens to the discovered nodes. Without this the
21
22
  // rediss:// scheme above would be a no-op and every real cluster connection would stay
@@ -24,7 +25,7 @@ export const redisClient = process.env.REDIS_IS_CLUSTER === '1'
24
25
  }
25
26
  })
26
27
  : /* c8 ignore stop */
27
- createClient({ url: resolveRedisUrl(process.env.REDIS_URL) });
28
+ createClient({ url: resolveRedisUrl(process.env['REDIS_URL']) }); // cast: see the cluster branch above
28
29
  export const RedisConnect = async () => {
29
30
  console.info('[Redis] Try connect to database... ');
30
31
  redisClient.on('error', (e) => {
@@ -6,7 +6,6 @@ interface IUserInfo {
6
6
  };
7
7
  }
8
8
  export declare class SocketLabsLib {
9
- private StringObj;
10
9
  private readonly platformName;
11
10
  private readonly linkBase;
12
11
  private readonly emailFrom;
@@ -30,10 +29,14 @@ export declare class SocketLabsLib {
30
29
  * normalised away — the caller supplies configuration, not a pre-joined URL, and `//check` or
31
30
  * `example.comcheck` are not errors worth surfacing to a user mid-registration.
32
31
  *
32
+ * The base, whether passed or taken from `APP_DOMAIN`, must parse as an absolute `http:` / `https:` URL
33
+ * with no user name, password, control character or whitespace; any other value (`javascript:`, `data:`,
34
+ * `//host`, a host with no scheme) makes the call reject with `throwInternalError()` and sends nothing.
35
+ *
33
36
  * @param emailTo recipient, also embedded in the link (URI-encoded)
34
37
  * @param hash the activation hash stored on the account
35
38
  * @param name optional greeting name
36
- * @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`
39
+ * @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`. An absolute `http:` / `https:` URL, else the call rejects with a 500
37
40
  * @param linkPath route prefix the receiving service listens on; defaults to `/check/verify-email`
38
41
  */
39
42
  sendEmailVerify(emailTo: string, hash: string, name?: string, linkBase?: string, linkPath?: string): Promise<boolean>;
@@ -116,7 +119,7 @@ SendResponse {
116
119
  * @param emailTo recipient, also embedded in the link (URI-encoded)
117
120
  * @param hash the reset hash stored on the account
118
121
  * @param name optional greeting name
119
- * @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`
122
+ * @param linkBase scheme + host the link points at; defaults to `APP_DOMAIN`. An absolute `http:` / `https:` URL, else the call rejects with a 500
120
123
  * @param linkPath front-end route prefix that renders the new-password form; defaults to `/x/reset`
121
124
  */
122
125
  sendEmailReset(emailTo: string, hash: string, name?: string, linkBase?: string, linkPath?: string): Promise<boolean>;
@@ -134,17 +137,5 @@ SendResponse {
134
137
  getHtmlHeader(title: string): string;
135
138
  getHtmlFooter(): string;
136
139
  private sendTemplate;
137
- private sendEmail;
138
- /**
139
- * fallback header
140
- * @private
141
- */
142
- private htmlHeader1;
143
- /**
144
- * fallback header
145
- * @private
146
- */
147
- private htmlHeader2;
148
- private fixName;
149
140
  }
150
141
  export {};