emailengine-app 2.75.0 → 2.77.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.
- package/.github/workflows/release.yaml +24 -19
- package/.github/workflows/test.yml +0 -10
- package/.ncurc.js +14 -2
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +38 -0
- package/README.md +1 -1
- package/config/e2e.toml +1 -1
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +71 -4
- package/lib/address-strategies.js +18 -0
- package/lib/api-reference/code-samples.js +194 -0
- package/lib/api-reference/format.js +179 -0
- package/lib/api-reference/index.js +205 -0
- package/lib/api-reference/model.js +336 -0
- package/lib/api-reference/schema-tree.js +366 -0
- package/lib/api-routes/account-routes.js +117 -37
- package/lib/api-routes/behavior-notes.js +54 -0
- package/lib/api-routes/blocklist-routes.js +9 -9
- package/lib/api-routes/changes-routes.js +6 -4
- package/lib/api-routes/chat-routes.js +3 -3
- package/lib/api-routes/delivery-test-routes.js +24 -6
- package/lib/api-routes/export-routes.js +14 -12
- package/lib/api-routes/gateway-routes.js +11 -11
- package/lib/api-routes/license-routes.js +7 -7
- package/lib/api-routes/mailbox-routes.js +18 -9
- package/lib/api-routes/message-routes.js +55 -35
- package/lib/api-routes/oauth2-app-routes.js +22 -16
- package/lib/api-routes/outbox-routes.js +7 -7
- package/lib/api-routes/pubsub-routes.js +3 -3
- package/lib/api-routes/route-helpers.js +3 -0
- package/lib/api-routes/settings-routes.js +10 -9
- package/lib/api-routes/stats-routes.js +3 -3
- package/lib/api-routes/submit-routes.js +213 -56
- package/lib/api-routes/template-routes.js +13 -13
- package/lib/api-routes/token-routes.js +15 -10
- package/lib/api-routes/webhook-route-routes.js +5 -5
- package/lib/consts.js +7 -0
- package/lib/email-client/base-client.js +230 -31
- package/lib/email-client/gmail/send-request.js +16 -1
- package/lib/email-client/gmail-client.js +89 -5
- package/lib/email-client/imap-client.js +103 -1
- package/lib/email-client/message-builder.js +24 -7
- package/lib/email-client/outlook/send-request.js +18 -1
- package/lib/email-client/outlook-client.js +79 -4
- package/lib/enum-descriptions.js +130 -0
- package/lib/imapproxy/imap-server.js +30 -26
- package/lib/imapproxy/upstream-client.js +38 -0
- package/lib/oauth2-apps.js +9 -3
- package/lib/openapi/build-document.js +318 -0
- package/lib/openapi/index.js +95 -0
- package/lib/openapi/joi-schema.js +523 -0
- package/lib/routes-ui.js +5 -1
- package/lib/schemas.js +76 -17
- package/lib/swagger-options.js +173 -0
- package/lib/tokens.js +69 -5
- package/lib/ui-routes/admin-entities-routes.js +3 -0
- package/lib/ui-routes/dashboard-routes.js +2 -26
- package/lib/ui-routes/reference-routes.js +195 -0
- package/lib/ui-routes/route-helpers.js +11 -0
- package/package.json +19 -26
- package/playwright.config.js +1 -1
- package/prepare-bundle-deps.sh +28 -0
- package/release-please-config.json +11 -0
- package/sbom.json +0 -1
- package/server.js +22 -2
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +90 -0
- package/static/js/ee-client.js +238 -8
- package/static/js/reference.js +736 -0
- package/static/js/ui.js +61 -33
- package/static/licenses.html +16 -16
- package/translations/messages.pot +13 -13
- package/views/config/ai.hbs +1 -1
- package/views/config/document-store/chat.hbs +5 -5
- package/views/config/document-store/index.hbs +2 -2
- package/views/config/document-store/pre-processing/index.hbs +1 -1
- package/views/config/email-processing.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/oauth/index.hbs +3 -3
- package/views/config/security.hbs +1 -1
- package/views/config/smtp.hbs +2 -2
- package/views/dashboard.hbs +1 -1
- package/views/layout/app.hbs +18 -7
- package/views/partials/oauth_form.hbs +4 -4
- package/views/partials/reference/anchor-link.hbs +20 -0
- package/views/partials/reference/disclosure.hbs +37 -0
- package/views/partials/reference/nav.hbs +93 -0
- package/views/partials/reference/operation.hbs +127 -0
- package/views/partials/reference/params.hbs +20 -0
- package/views/partials/reference/schema-node.hbs +99 -0
- package/views/partials/reference/schema.hbs +19 -0
- package/views/partials/reference/section-heading.hbs +16 -0
- package/views/partials/reference/token-alert.hbs +24 -0
- package/views/partials/reference/try-field.hbs +31 -0
- package/views/partials/reference/try-it.hbs +78 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/badge.hbs +4 -2
- package/views/partials/ui/page-header.hbs +1 -1
- package/views/partials/ui/search-input.hbs +31 -0
- package/views/partials/ui/setting-ref.hbs +1 -1
- package/views/partials/ui/stat-card.hbs +4 -2
- package/views/partials/ui/tab.hbs +6 -1
- package/views/partials/ui/tabs.hbs +2 -2
- package/views/reference/index.hbs +76 -0
- package/views/reference/redirect.hbs +49 -0
- package/views/reference/tag.hbs +28 -0
- package/views/reference/token.hbs +49 -0
- package/views/tokens/index.hbs +9 -1
- package/views/webhooks/index.hbs +3 -3
- package/workers/api.js +37 -215
- package/Gruntfile.js +0 -58
- package/views/swagger/index.hbs +0 -82
|
@@ -21,31 +21,36 @@ jobs:
|
|
|
21
21
|
patch: ${{ steps.release.outputs.patch }}
|
|
22
22
|
release_created: ${{ steps.release.outputs.release_created }}
|
|
23
23
|
steps:
|
|
24
|
+
# Configured through release-please-config.json (manifest mode) rather than a
|
|
25
|
+
# `release-type` input here - the two are mutually exclusive, and only the config
|
|
26
|
+
# file can set `draft`, which the action exposes no input for. The release is drafted
|
|
27
|
+
# so users never see a version whose binaries do not exist yet, and `force-tag-creation`
|
|
28
|
+
# makes the tag anyway: GitHub withholds the tag for a draft, and upload.sh builds
|
|
29
|
+
# from the tag (falling back to HEAD behind an interactive prompt without it).
|
|
24
30
|
- uses: googleapis/release-please-action@v4
|
|
25
31
|
id: release
|
|
26
|
-
with:
|
|
27
|
-
release-type: node
|
|
28
|
-
|
|
29
|
-
# The logic below handles the npm publication:
|
|
30
|
-
- uses: actions/checkout@v6
|
|
31
|
-
# these if statements ensure that a publication only occurs when
|
|
32
|
-
# a new release is created:
|
|
33
|
-
if: ${{ steps.release.outputs.release_created }}
|
|
34
|
-
|
|
35
|
-
- uses: actions/setup-node@v6
|
|
36
|
-
with:
|
|
37
|
-
node-version: 24
|
|
38
|
-
registry-url: "https://registry.npmjs.org"
|
|
39
|
-
if: ${{ steps.release.outputs.release_created }}
|
|
40
|
-
|
|
41
|
-
- run: npm install
|
|
42
|
-
if: ${{ steps.release.outputs.release_created }}
|
|
43
32
|
|
|
44
33
|
publish:
|
|
45
34
|
name: Publish NPM package
|
|
46
35
|
runs-on: ubuntu-latest
|
|
47
36
|
needs: release_please
|
|
48
|
-
|
|
37
|
+
# Fires as soon as release-please creates the release, which it does even though the
|
|
38
|
+
# release is a draft - `release_created` reports the release object, not its visibility.
|
|
39
|
+
#
|
|
40
|
+
# Deliberately NOT deferred until the draft is published. Doing that would mean waiting
|
|
41
|
+
# on a `release` event, and that event only exists because upload.sh publishes with a
|
|
42
|
+
# real user's credentials: draft releases raise no event, and one raised inside Actions
|
|
43
|
+
# by GITHUB_TOKEN never triggers a workflow. Several conditions all having to hold for a
|
|
44
|
+
# publish to happen makes the failure mode a silent non-publication, discovered late.
|
|
45
|
+
# Publishing here is one workflow run with nothing to choreograph.
|
|
46
|
+
#
|
|
47
|
+
# Publishing before the binaries exist is not shipping something broken: the npm package
|
|
48
|
+
# is the Node source and works on its own - it does not carry the pkg binaries, so it
|
|
49
|
+
# does not depend on the part of a release that can fail late.
|
|
50
|
+
#
|
|
51
|
+
# This job also has to stay in this file: npm trusted publishing (OIDC, which is why
|
|
52
|
+
# there is no token secret) is bound to the repository AND the workflow filename.
|
|
53
|
+
if: needs.release_please.outputs.release_created
|
|
49
54
|
permissions:
|
|
50
55
|
contents: read
|
|
51
56
|
id-token: write
|
|
@@ -62,7 +67,7 @@ jobs:
|
|
|
62
67
|
name: Publish Tagged Docker Image
|
|
63
68
|
runs-on: ubuntu-latest
|
|
64
69
|
needs: release_please
|
|
65
|
-
if:
|
|
70
|
+
if: needs.release_please.outputs.release_created
|
|
66
71
|
# Multi-arch builds run the arm64 leg under QEMU emulation, which can
|
|
67
72
|
# hang indefinitely on a misbehaving step. A normal build finishes in
|
|
68
73
|
# ~4 minutes, so fail fast instead of burning the 6-hour default limit.
|
|
@@ -78,11 +78,6 @@ jobs:
|
|
|
78
78
|
with:
|
|
79
79
|
node-version: 24
|
|
80
80
|
cache: npm
|
|
81
|
-
- name: Setup Redis CLI
|
|
82
|
-
uses: shogo82148/actions-setup-redis@v1
|
|
83
|
-
with:
|
|
84
|
-
redis-version: '7.x'
|
|
85
|
-
auto-start: 'false'
|
|
86
81
|
- run: npm install
|
|
87
82
|
- name: Run unit tests
|
|
88
83
|
run: |
|
|
@@ -157,11 +152,6 @@ jobs:
|
|
|
157
152
|
with:
|
|
158
153
|
node-version: 24
|
|
159
154
|
cache: npm
|
|
160
|
-
- name: Setup Redis CLI
|
|
161
|
-
uses: shogo82148/actions-setup-redis@v1
|
|
162
|
-
with:
|
|
163
|
-
redis-version: '7.x'
|
|
164
|
-
auto-start: 'false'
|
|
165
155
|
- run: npm install
|
|
166
156
|
- name: Run integration tests
|
|
167
157
|
run: |
|
package/.ncurc.js
CHANGED
|
@@ -4,8 +4,8 @@ module.exports = {
|
|
|
4
4
|
// CommonJS and is bundled into a binary with pkg) or it breaks a peer dependency. Using 'minor'
|
|
5
5
|
// instead of a blanket reject so these still receive security/patch updates within the safe
|
|
6
6
|
// major instead of being frozen at one exact version. Verified against Node 20 (Docker) 2026-06-17.
|
|
7
|
-
target: name =>
|
|
8
|
-
|
|
7
|
+
target: name =>
|
|
8
|
+
['nanoid', 'ical.js', 'gettext-parser', 'xgettext-template', 'chai', 'undici', 'marked', 'bullmq', 'ioredis'].includes(name) ? 'minor' : 'latest',
|
|
9
9
|
// nanoid - 4.x dropped the CommonJS require export (ESM-only)
|
|
10
10
|
// ical.js - 2.x is ESM-only
|
|
11
11
|
// gettext-parser - 8.x is ESM-only
|
|
@@ -14,6 +14,18 @@ module.exports = {
|
|
|
14
14
|
// undici - 8.x requires Node >=22.19 and crashes at require() on Node 20; EmailEngine supports Node 20+
|
|
15
15
|
// marked - 16.x dropped the CommonJS build (ESM-only, needs require(esm)/Node >=20.19); 15.x is the
|
|
16
16
|
// last require()-compatible line. 15.0.12 verified on Node 20-24 and in a yao/pkg node24 build.
|
|
17
|
+
// bullmq - 6.x drops ioredis entirely, and @bull-board/api still peer-requires bullmq ^5.79.2, so the
|
|
18
|
+
// install fails outright (ERESOLVE) on the queue browser we mount at /admin/bull-board.
|
|
19
|
+
// Lift when bull-board ships bullmq 6 support.
|
|
20
|
+
// ioredis - 6.x is held back BY the bullmq cap above, not on its own merits. lib/db.js creates the
|
|
21
|
+
// client and hands it to bullmq as `connection` for all four queues, while bullmq 5 pins
|
|
22
|
+
// ioredis 5.11.1 as a direct dependency - so bumping ours to 6 would drive bullmq 5's
|
|
23
|
+
// internals with a client it was not written against. These two move together.
|
|
24
|
+
//
|
|
25
|
+
// joi used to be capped here because hapi-swagger peer-required 17.x. That dependency is gone
|
|
26
|
+
// (the OpenAPI document is generated by lib/openapi/ now), so joi may move majors again. A major
|
|
27
|
+
// bump still needs a look at the generated document: test/openapi-golden-test.js fails if joi's
|
|
28
|
+
// describe() output changes shape.
|
|
17
29
|
reject: [
|
|
18
30
|
// 8.16+ pulls apache-arrow (ESM) into the pkg bundle; 9.x drops it but is a major bump for
|
|
19
31
|
// the deprecated, default-off Document Store. Even the 8.19 minor is unsafe to bundle.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.77.0](https://github.com/postalsys/emailengine/compare/v2.76.0...v2.77.0) (2026-08-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **admin:** make the API reference searchable by field name and linkable per property ([65acf52](https://github.com/postalsys/emailengine/commit/65acf52a79d0002d7cd7cec7e2466f17dea06f13))
|
|
9
|
+
* **admin:** retire the bundled swagger-ui page ([34eb957](https://github.com/postalsys/emailengine/commit/34eb9579b19211b678283d2af62fee7c876ba6f0))
|
|
10
|
+
* **admin:** server-rendered API reference at /admin/reference ([2ae59f9](https://github.com/postalsys/emailengine/commit/2ae59f9377f0f651324e9fbed65970ffaf72c3f5))
|
|
11
|
+
* **api:** document success responses, enum values and per-operation behavior ([bbe36e6](https://github.com/postalsys/emailengine/commit/bbe36e6d0a2c9fb36fc1fb00fdd5f1d7b5d3cc0d))
|
|
12
|
+
* **api:** generate the OpenAPI document without hapi-swagger ([4a87b29](https://github.com/postalsys/emailengine/commit/4a87b2953d136cbc1f9e44786c7dab2d3ce1cc34))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **api:** declare the success response for streaming and binary endpoints ([633362e](https://github.com/postalsys/emailengine/commit/633362e14924ee57709d18405794577285cf287f))
|
|
18
|
+
* **assignment:** do not 500 when an account is created before the first worker is ready ([7c8e5df](https://github.com/postalsys/emailengine/commit/7c8e5dfaf8e06458b124b5c740a1ad917ff76f94))
|
|
19
|
+
* **deps:** update dependencies (@postalsys/ee-client 1.7.0) ([9c440b2](https://github.com/postalsys/emailengine/commit/9c440b2c4e94f975267a0562022bdebc86524c9f))
|
|
20
|
+
* **encrypt:** rotate every stored secret, not just the ones the tool remembered ([35a2cc0](https://github.com/postalsys/emailengine/commit/35a2cc0886c718945f94989799aeef7cda1db8f3))
|
|
21
|
+
* **imapproxy:** keep an error sink on the upstream proxy connection ([653259d](https://github.com/postalsys/emailengine/commit/653259d7e5a9558489eccea1ead8c50856274dd2))
|
|
22
|
+
* **oauth2:** honor useAuthServer on the IMAP and SMTP paths ([0c5c43d](https://github.com/postalsys/emailengine/commit/0c5c43da4b4190bba4e41ecbfa4c24b2e8627397))
|
|
23
|
+
* **openapi:** do not shadow require() in the schema converter ([a63bf90](https://github.com/postalsys/emailengine/commit/a63bf90435eef459513e78f7ed549607923d428a))
|
|
24
|
+
* **tokens:** reap expired tokens from the listing, not only on use ([2564831](https://github.com/postalsys/emailengine/commit/2564831d1b533b26a0c07dabd981a01a36c21e08))
|
|
25
|
+
|
|
26
|
+
## [2.76.0](https://github.com/postalsys/emailengine/compare/v2.75.0...v2.76.0) (2026-07-29)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* add an API endpoint for sending stored drafts ([16e759a](https://github.com/postalsys/emailengine/commit/16e759aab429160d312827618841222c7704057d))
|
|
32
|
+
* add EENGINE_UPDATE_CHECK_DISABLED to opt out of the GitHub update check ([e92bfe6](https://github.com/postalsys/emailengine/commit/e92bfe6e9b01ae9abe1cc782b51d39aac94b2341))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* **deps:** update dependencies (imapflow 1.6.3) ([7dc423c](https://github.com/postalsys/emailengine/commit/7dc423cafe45206c36b8293f1a57f47f56594dfe))
|
|
38
|
+
* **deps:** update dependencies (imapflow 1.6.5) ([6a350e1](https://github.com/postalsys/emailengine/commit/6a350e1ab7e8b96ae089d0768c2a9300e0a405e0))
|
|
39
|
+
* **imap:** stop re-listing the folders on every connection setup ([6d79eb3](https://github.com/postalsys/emailengine/commit/6d79eb3f67a3d2bb826f43483c4e51d03ea98d8a))
|
|
40
|
+
|
|
3
41
|
## [2.75.0](https://github.com/postalsys/emailengine/compare/v2.74.2...v2.75.0) (2026-07-28)
|
|
4
42
|
|
|
5
43
|
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ A headless email client application that provides access to IMAP, SMTP, Gmail AP
|
|
|
58
58
|
|
|
59
59
|
- [Documentation](https://learn.emailengine.app/)
|
|
60
60
|
- [API Reference](https://learn.emailengine.app/docs/api/emailengine-api)
|
|
61
|
-
- OpenAPI specification for Postman and code generators: every instance serves its own at `/swagger.json
|
|
61
|
+
- OpenAPI specification for Postman and code generators: every instance serves its own at `/swagger.json`. To work against a specific version instead, download [the copy published with each release](https://go.emailengine.app/swagger.json) - it describes exactly the release it ships with, while [emailengine.dev/swagger.json](https://emailengine.dev/swagger.json) tracks the latest build.
|
|
62
62
|
|
|
63
63
|
## Configuring EmailEngine
|
|
64
64
|
|
package/config/e2e.toml
CHANGED
package/encrypt.js
CHANGED
|
@@ -18,7 +18,8 @@ const { encryptedKeys } = require('./lib/settings');
|
|
|
18
18
|
const getSecret = require('./lib/get-secret');
|
|
19
19
|
const msgpack = require('msgpack5')();
|
|
20
20
|
|
|
21
|
-
const { REDIS_PREFIX } = require('./lib/consts');
|
|
21
|
+
const { REDIS_PREFIX, ENCRYPTED_APP_KEYS } = require('./lib/consts');
|
|
22
|
+
const { Settings: CertSettings } = require('@postalsys/certs/lib/settings');
|
|
22
23
|
|
|
23
24
|
const DECRYPT_PASSWORDS = [].concat(config.decrypt || []);
|
|
24
25
|
|
|
@@ -175,7 +176,10 @@ async function main() {
|
|
|
175
176
|
console.log(`Updated ${updatedAccounts}/${accounts.length} accounts`);
|
|
176
177
|
|
|
177
178
|
let updatedGateways = 0;
|
|
178
|
-
|
|
179
|
+
// NB: the index set is `gateways`, not `ia:gateways` - see lib/gateway.js. Reading the wrong
|
|
180
|
+
// key made this loop report `0/0` on every rotation while leaving gateway passwords encrypted
|
|
181
|
+
// with the old secret.
|
|
182
|
+
let gateways = await redis.smembers(`${REDIS_PREFIX}gateways`);
|
|
179
183
|
for (let gateway of gateways) {
|
|
180
184
|
let pass = await redis.hget(`${REDIS_PREFIX}gateway:${gateway}`, 'pass');
|
|
181
185
|
if (!pass) {
|
|
@@ -218,7 +222,7 @@ async function main() {
|
|
|
218
222
|
|
|
219
223
|
try {
|
|
220
224
|
let appUpdated = false;
|
|
221
|
-
for (let key of
|
|
225
|
+
for (let key of ENCRYPTED_APP_KEYS) {
|
|
222
226
|
if (entry[key]) {
|
|
223
227
|
let value = await processSecret(entry[key], encryptSecret);
|
|
224
228
|
if (value !== entry[key]) {
|
|
@@ -238,11 +242,74 @@ async function main() {
|
|
|
238
242
|
updatedApps++;
|
|
239
243
|
}
|
|
240
244
|
} catch (err) {
|
|
241
|
-
console.error(`Could not process
|
|
245
|
+
console.error(`Could not process encrypted values for OAuth2 App ${app}. Check decryption secrets.`);
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
console.log(`Updated ${updatedApps}/${apps.length} OAuth2 apps`);
|
|
250
|
+
|
|
251
|
+
// TLS private keys managed by @postalsys/certs. These live in the module's own hash, not in the
|
|
252
|
+
// EmailEngine settings hash, so they need their own pass - without it a rotation leaves the ACME
|
|
253
|
+
// account key and every domain key readable only with the old secret, and TLS fails on the next
|
|
254
|
+
// renewal with no self-healing path. Every field in that hash is msgpack encoded; only the ACME
|
|
255
|
+
// account's `privateKey` and the `domain:<name>:privateKey` entries hold encrypted values.
|
|
256
|
+
let updatedCerts = 0;
|
|
257
|
+
// Ask the library for the key instead of rebuilding it here: the namespace it is constructed
|
|
258
|
+
// with is `${REDIS_PREFIX}`, and it appends its own separator, so the hash is
|
|
259
|
+
// `certs:settings` unprefixed but `<prefix>::certs:settings` when EENGINE_REDIS_PREFIX is set.
|
|
260
|
+
let certsKey = CertSettings.create({ namespace: `${REDIS_PREFIX}` }).getKey('settings');
|
|
261
|
+
let certEntries = await redis.hgetallBuffer(certsKey);
|
|
262
|
+
for (let field of Object.keys(certEntries || {})) {
|
|
263
|
+
let isAcmeAccount = /^account:/.test(field);
|
|
264
|
+
let isDomainKey = /^domain:.*:privateKey$/.test(field);
|
|
265
|
+
if (!isAcmeAccount && !isDomainKey) {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let entry;
|
|
270
|
+
try {
|
|
271
|
+
entry = msgpack.decode(certEntries[field]);
|
|
272
|
+
} catch (err) {
|
|
273
|
+
console.log(`Certificate entry ${field}: failed to parse`);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
let value;
|
|
279
|
+
if (isAcmeAccount) {
|
|
280
|
+
if (!entry || !entry.privateKey) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
let updated = await processSecret(entry.privateKey, encryptSecret);
|
|
284
|
+
if (updated === entry.privateKey) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
entry.privateKey = updated;
|
|
288
|
+
value = entry;
|
|
289
|
+
} else {
|
|
290
|
+
if (!entry) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
let updated = await processSecret(entry, encryptSecret);
|
|
294
|
+
if (updated === entry) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
value = updated;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let result = await redis.hmset(certsKey, { [field]: msgpack.encode(value) });
|
|
301
|
+
if (result === 'OK') {
|
|
302
|
+
console.log(`Certificate entry ${field}: updated`);
|
|
303
|
+
} else {
|
|
304
|
+
console.log(`Certificate entry ${field}: Unexpected response from DB: ${result}`);
|
|
305
|
+
}
|
|
306
|
+
updatedCerts++;
|
|
307
|
+
} catch (err) {
|
|
308
|
+
console.error(`Could not process "${field}". Check decryption secrets.`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
console.log(`Updated ${updatedCerts} TLS private keys`);
|
|
246
313
|
}
|
|
247
314
|
|
|
248
315
|
main()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The local-address selection strategies, shared by the joi schemas (which use the keys as
|
|
4
|
+
// the allowed value set), the admin UI (which shows the titles), and lib/enum-descriptions.js
|
|
5
|
+
// (which documents each value in the API reference). One table so a new strategy cannot be
|
|
6
|
+
// half-added.
|
|
7
|
+
|
|
8
|
+
const ADDRESS_STRATEGIES = [
|
|
9
|
+
{ key: 'default', title: 'Default', description: 'Let the operating system pick the source address' },
|
|
10
|
+
{
|
|
11
|
+
key: 'dedicated',
|
|
12
|
+
title: 'Dedicated',
|
|
13
|
+
description: 'Reuse the same local address for an account, so the remote server sees a stable IP'
|
|
14
|
+
},
|
|
15
|
+
{ key: 'random', title: 'Random', description: 'Pick a random local address for every connection' }
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
module.exports = { ADDRESS_STRATEGIES };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Ready-to-run request samples for an operation. Generated per request because the
|
|
4
|
+
// base URL comes from the request the reference page was loaded with, so an instance
|
|
5
|
+
// behind a proxy shows the address the caller actually reaches it on.
|
|
6
|
+
//
|
|
7
|
+
// Samples are illustrative: path parameters are filled from their schema examples and
|
|
8
|
+
// only required query parameters are included, so the snippet is runnable after
|
|
9
|
+
// swapping in a real account id and access token.
|
|
10
|
+
|
|
11
|
+
// All three samples read the token from the same environment variable so the page can
|
|
12
|
+
// document it once and the snippets stay copy-paste runnable without editing them.
|
|
13
|
+
const TOKEN_ENV_VAR = 'EMAILENGINE_TOKEN';
|
|
14
|
+
|
|
15
|
+
const INDENT = ' ';
|
|
16
|
+
|
|
17
|
+
function buildUrl(baseUrl, operation) {
|
|
18
|
+
let path = operation.path;
|
|
19
|
+
|
|
20
|
+
for (const parameter of operation.pathParams) {
|
|
21
|
+
path = path.replace(`{${parameter.name}}`, encodeURIComponent(parameter.sampleValue));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const query = operation.queryParams
|
|
25
|
+
.filter(parameter => parameter.required)
|
|
26
|
+
.map(parameter => `${encodeURIComponent(parameter.name)}=${encodeURIComponent(parameter.sampleValue)}`);
|
|
27
|
+
|
|
28
|
+
return `${baseUrl}${path}${query.length ? `?${query.join('&')}` : ''}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Single-quoted shell strings cannot contain a single quote, so each one closes the
|
|
32
|
+
// string, adds an escaped quote and reopens it.
|
|
33
|
+
function shellQuote(value) {
|
|
34
|
+
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function curlSample(url, operation, bodyJson) {
|
|
38
|
+
const lines = [`curl -X ${operation.methodLabel} ${shellQuote(url)} \\`, `${INDENT}-H "Authorization: Bearer $${TOKEN_ENV_VAR}"`];
|
|
39
|
+
|
|
40
|
+
if (bodyJson) {
|
|
41
|
+
lines[lines.length - 1] += ' \\';
|
|
42
|
+
lines.push(`${INDENT}-H "Content-Type: application/json" \\`);
|
|
43
|
+
lines.push(`${INDENT}-d ${shellQuote(bodyJson)}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return lines.join('\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function nodeSample(url, operation, bodyJson) {
|
|
50
|
+
const lines = [
|
|
51
|
+
`const response = await fetch(${JSON.stringify(url)}, {`,
|
|
52
|
+
`${INDENT}method: ${JSON.stringify(operation.methodLabel)},`,
|
|
53
|
+
`${INDENT}headers: {`
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const headers = [`${INDENT}${INDENT}Authorization: \`Bearer \${accessToken}\``];
|
|
57
|
+
if (bodyJson) {
|
|
58
|
+
headers.push(`${INDENT}${INDENT}'Content-Type': 'application/json'`);
|
|
59
|
+
}
|
|
60
|
+
lines.push(headers.join(',\n'));
|
|
61
|
+
lines.push(`${INDENT}}${bodyJson ? ',' : ''}`);
|
|
62
|
+
|
|
63
|
+
if (bodyJson) {
|
|
64
|
+
const body = bodyJson
|
|
65
|
+
.split('\n')
|
|
66
|
+
.map((line, index) => (index === 0 ? line : `${INDENT}${line}`))
|
|
67
|
+
.join('\n');
|
|
68
|
+
lines.push(`${INDENT}body: JSON.stringify(${body})`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
lines.push('});');
|
|
72
|
+
lines.push('');
|
|
73
|
+
lines.push('const data = await response.json();');
|
|
74
|
+
|
|
75
|
+
return `const accessToken = process.env.${TOKEN_ENV_VAR};\n\n${lines.join('\n')}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// JSON literals do not survive a paste into Python (true/false/null), so the example
|
|
79
|
+
// value is re-emitted with Python literals instead of string-replacing the JSON.
|
|
80
|
+
function pythonLiteral(value, indent) {
|
|
81
|
+
const pad = INDENT.repeat(indent);
|
|
82
|
+
const padInner = INDENT.repeat(indent + 1);
|
|
83
|
+
|
|
84
|
+
if (value === null) {
|
|
85
|
+
return 'None';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
if (!value.length) {
|
|
90
|
+
return '[]';
|
|
91
|
+
}
|
|
92
|
+
const items = value.map(item => `${padInner}${pythonLiteral(item, indent + 1)}`);
|
|
93
|
+
return `[\n${items.join(',\n')}\n${pad}]`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
switch (typeof value) {
|
|
97
|
+
case 'boolean':
|
|
98
|
+
return value ? 'True' : 'False';
|
|
99
|
+
case 'number':
|
|
100
|
+
return String(value);
|
|
101
|
+
case 'object': {
|
|
102
|
+
const keys = Object.keys(value);
|
|
103
|
+
if (!keys.length) {
|
|
104
|
+
return '{}';
|
|
105
|
+
}
|
|
106
|
+
const entries = keys.map(key => `${padInner}${JSON.stringify(key)}: ${pythonLiteral(value[key], indent + 1)}`);
|
|
107
|
+
return `{\n${entries.join(',\n')}\n${pad}}`;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
return JSON.stringify(String(value));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function pythonSample(url, operation, bodyValue) {
|
|
115
|
+
const lines = ['import os', 'import requests', '', `access_token = os.environ["${TOKEN_ENV_VAR}"]`, ''];
|
|
116
|
+
|
|
117
|
+
const args = [`${INDENT}${JSON.stringify(url)},`, `${INDENT}headers={"Authorization": f"Bearer {access_token}"},`];
|
|
118
|
+
|
|
119
|
+
if (typeof bodyValue !== 'undefined') {
|
|
120
|
+
args.push(`${INDENT}json=${pythonLiteral(bodyValue, 1)},`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
lines.push(`response = requests.${operation.method}(`);
|
|
124
|
+
lines.push(args.join('\n'));
|
|
125
|
+
lines.push(')');
|
|
126
|
+
lines.push('');
|
|
127
|
+
lines.push('print(response.json())');
|
|
128
|
+
|
|
129
|
+
return lines.join('\n');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// A hljs class has to be a bare token, and `lang` is free text from the document. Kept to
|
|
133
|
+
// the characters real language names use (c++, c#, objective-c, shell-session) so nothing
|
|
134
|
+
// else can end up in the class attribute.
|
|
135
|
+
function highlightLanguage(lang) {
|
|
136
|
+
return String(lang)
|
|
137
|
+
.toLowerCase()
|
|
138
|
+
.replace(/[^a-z0-9+#._-]/g, '');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Hand-written samples from an operation's `x-codeSamples` extension - the de-facto
|
|
142
|
+
// standard for this, read by Redoc and Scalar too. A route declares them in its
|
|
143
|
+
// `plugins.openapi` block, and lib/openapi/ publishes any `x-*` key verbatim, so they reach
|
|
144
|
+
// every consumer of /swagger.json rather than only this page.
|
|
145
|
+
//
|
|
146
|
+
// Only the current spelling is accepted. Redoc's older `x-code-samples` exists in documents
|
|
147
|
+
// written by hand or by other tools; ours is generated in-house from the route table, so it
|
|
148
|
+
// can only ever contain what our own routes declare.
|
|
149
|
+
//
|
|
150
|
+
// Entries that are not `{ lang, source }` are dropped rather than rendered as blanks: the
|
|
151
|
+
// extension is free-form, and a malformed one should cost its own tab, not the page.
|
|
152
|
+
//
|
|
153
|
+
// Normalized once when the model is built, since nothing here depends on the request.
|
|
154
|
+
function readCodeSamples(specOperation) {
|
|
155
|
+
const declared = specOperation['x-codeSamples'];
|
|
156
|
+
|
|
157
|
+
if (!Array.isArray(declared)) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return declared
|
|
162
|
+
.filter(sample => sample && typeof sample.lang === 'string' && typeof sample.source === 'string')
|
|
163
|
+
.map((sample, index) => ({
|
|
164
|
+
id: `custom-${index}`,
|
|
165
|
+
label: typeof sample.label === 'string' && sample.label ? sample.label : sample.lang,
|
|
166
|
+
language: highlightLanguage(sample.lang),
|
|
167
|
+
code: sample.source
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Returns the tab set rendered under an operation. `bodyValue` is the synthesized
|
|
172
|
+
// request example (undefined for operations with no request body).
|
|
173
|
+
//
|
|
174
|
+
// Hand-written samples come first: someone wrote one for this operation because the
|
|
175
|
+
// synthesized snippets did not tell the story, which only works if it is the tab that
|
|
176
|
+
// opens.
|
|
177
|
+
function buildCodeSamples(operation, baseUrl, bodyValue, bodyJson) {
|
|
178
|
+
const url = buildUrl(baseUrl, operation);
|
|
179
|
+
|
|
180
|
+
return [
|
|
181
|
+
...(operation.codeSamples || []),
|
|
182
|
+
{ id: 'curl', label: 'curl', language: 'bash', code: curlSample(url, operation, bodyJson) },
|
|
183
|
+
{ id: 'node', label: 'Node.js', language: 'javascript', code: nodeSample(url, operation, bodyJson) },
|
|
184
|
+
{ id: 'python', label: 'Python', language: 'python', code: pythonSample(url, operation, bodyValue) }
|
|
185
|
+
// Tab ids are composed here for the same reason as the response tabs: ui/tabs
|
|
186
|
+
// neutralizes its hash params inside the partial block, so the operation id is
|
|
187
|
+
// not reachable from the template
|
|
188
|
+
].map((sample, index) => Object.assign({}, sample, { tabId: `${operation.id}-sample-${sample.id}`, active: index === 0 }));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
module.exports = {
|
|
192
|
+
buildCodeSamples,
|
|
193
|
+
readCodeSamples
|
|
194
|
+
};
|