@budibase/worker 2.11.36 → 2.11.38
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/package.json +6 -7
- package/src/index.ts +2 -18
- package/src/utilities/email.ts +13 -13
- package/src/utilities/index.ts +2 -2
- package/src/utilities/redis.ts +14 -14
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.11.
|
|
4
|
+
"version": "2.11.38",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -38,12 +38,11 @@
|
|
|
38
38
|
"author": "Budibase",
|
|
39
39
|
"license": "GPL-3.0",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@budibase/backend-core": "2.11.
|
|
42
|
-
"@budibase/pro": "2.11.
|
|
43
|
-
"@budibase/string-templates": "2.11.
|
|
44
|
-
"@budibase/types": "2.11.
|
|
41
|
+
"@budibase/backend-core": "2.11.38",
|
|
42
|
+
"@budibase/pro": "2.11.38",
|
|
43
|
+
"@budibase/string-templates": "2.11.38",
|
|
44
|
+
"@budibase/types": "2.11.38",
|
|
45
45
|
"@koa/router": "8.0.8",
|
|
46
|
-
"@sentry/node": "6.17.7",
|
|
47
46
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
48
47
|
"@types/global-agent": "2.1.1",
|
|
49
48
|
"aws-sdk": "2.1030.0",
|
|
@@ -108,5 +107,5 @@
|
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
},
|
|
111
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "ec768a59f56e7aabc38e2e8bf0defe9e91a3f7e6"
|
|
112
111
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,6 @@ if (process.env.DD_APM_ENABLED) {
|
|
|
4
4
|
|
|
5
5
|
// need to load environment first
|
|
6
6
|
import env from "./environment"
|
|
7
|
-
import { Scope } from "@sentry/node"
|
|
8
|
-
import { Event } from "@sentry/types/dist/event"
|
|
9
7
|
import Application from "koa"
|
|
10
8
|
import { bootstrap } from "global-agent"
|
|
11
9
|
import * as db from "./db"
|
|
@@ -25,9 +23,9 @@ import koaBody from "koa-body"
|
|
|
25
23
|
import http from "http"
|
|
26
24
|
import api from "./api"
|
|
27
25
|
import * as redis from "./utilities/redis"
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
const koaSession = require("koa-session")
|
|
30
|
-
|
|
28
|
+
import { userAgent } from "koa-useragent"
|
|
31
29
|
|
|
32
30
|
import destroyable from "server-destroy"
|
|
33
31
|
import { initPro } from "./initPro"
|
|
@@ -66,20 +64,6 @@ app.use(auth.passport.session())
|
|
|
66
64
|
// api routes
|
|
67
65
|
app.use(api.routes())
|
|
68
66
|
|
|
69
|
-
// sentry
|
|
70
|
-
if (env.isProd()) {
|
|
71
|
-
Sentry.init()
|
|
72
|
-
|
|
73
|
-
app.on("error", (err, ctx) => {
|
|
74
|
-
Sentry.withScope(function (scope: Scope) {
|
|
75
|
-
scope.addEventProcessor(function (event: Event) {
|
|
76
|
-
return Sentry.Handlers.parseRequest(event, ctx.request)
|
|
77
|
-
})
|
|
78
|
-
Sentry.captureException(err)
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
67
|
const server = http.createServer(app.callback())
|
|
84
68
|
destroyable(server)
|
|
85
69
|
|
package/src/utilities/email.ts
CHANGED
|
@@ -71,12 +71,12 @@ async function getLinkCode(
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Builds an email using handlebars and the templates found in the system (default or otherwise).
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @return
|
|
74
|
+
* @param purpose the purpose of the email being built, e.g. invitation, password reset.
|
|
75
|
+
* @param email the address which it is being sent to for contextual purposes.
|
|
76
|
+
* @param context the context which is being used for building the email (hbs context).
|
|
77
|
+
* @param user if being sent to an existing user then the object can be provided for context.
|
|
78
|
+
* @param contents if using a custom template can supply contents for context.
|
|
79
|
+
* @return returns the built email HTML if all provided parameters were valid.
|
|
80
80
|
*/
|
|
81
81
|
async function buildEmail(
|
|
82
82
|
purpose: EmailTemplatePurpose,
|
|
@@ -128,7 +128,7 @@ async function buildEmail(
|
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* Checks if a SMTP config exists based on passed in parameters.
|
|
131
|
-
* @return
|
|
131
|
+
* @return returns true if there is a configuration that can be used.
|
|
132
132
|
*/
|
|
133
133
|
export async function isEmailConfigured() {
|
|
134
134
|
// when "testing" or smtp fallback is enabled simply return true
|
|
@@ -142,10 +142,10 @@ export async function isEmailConfigured() {
|
|
|
142
142
|
/**
|
|
143
143
|
* Given an email address and an email purpose this will retrieve the SMTP configuration and
|
|
144
144
|
* send an email using it.
|
|
145
|
-
* @param
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @return
|
|
145
|
+
* @param email The email address to send to.
|
|
146
|
+
* @param purpose The purpose of the email being sent (e.g. reset password).
|
|
147
|
+
* @param opts The options for sending the email.
|
|
148
|
+
* @return returns details about the attempt to send email, e.g. if it is successful; based on
|
|
149
149
|
* nodemailer response.
|
|
150
150
|
*/
|
|
151
151
|
export async function sendEmail(
|
|
@@ -212,8 +212,8 @@ export async function sendEmail(
|
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
214
|
* Given an SMTP configuration this runs it through nodemailer to see if it is in fact functional.
|
|
215
|
-
* @param
|
|
216
|
-
* @return
|
|
215
|
+
* @param config an SMTP configuration - this is based on the nodemailer API.
|
|
216
|
+
* @return returns true if the configuration is valid.
|
|
217
217
|
*/
|
|
218
218
|
export async function verifyConfig(config: SMTPInnerConfig) {
|
|
219
219
|
const transport = createSMTPTransport(config)
|
package/src/utilities/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Makes sure that a URL has the correct number of slashes, while maintaining the
|
|
3
3
|
* http(s):// double slashes.
|
|
4
|
-
* @param
|
|
5
|
-
* @return
|
|
4
|
+
* @param url The URL to test and remove any extra double slashes.
|
|
5
|
+
* @return The updated url.
|
|
6
6
|
*/
|
|
7
7
|
export function checkSlashesInUrl(url: string) {
|
|
8
8
|
return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
|
package/src/utilities/redis.ts
CHANGED
|
@@ -37,8 +37,8 @@ async function updateACode(db: string, code: string, value: any) {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Given an invite code and invite body, allow the update an existing/valid invite in redis
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
40
|
+
* @param inviteCode The invite code for an invite in redis
|
|
41
|
+
* @param value The body of the updated user invitation
|
|
42
42
|
*/
|
|
43
43
|
export async function updateInviteCode(inviteCode: string, value: string) {
|
|
44
44
|
await updateACode(redis.utils.Databases.INVITATIONS, inviteCode, value)
|
|
@@ -77,9 +77,9 @@ export async function shutdown() {
|
|
|
77
77
|
/**
|
|
78
78
|
* Given a user ID this will store a code (that is returned) for an hour in redis.
|
|
79
79
|
* The user can then return this code for resetting their password (through their reset link).
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
82
|
-
* @return
|
|
80
|
+
* @param userId the ID of the user which is to be reset.
|
|
81
|
+
* @param info Info about the user/the reset process.
|
|
82
|
+
* @return returns the code that was stored to redis.
|
|
83
83
|
*/
|
|
84
84
|
export async function getResetPasswordCode(userId: string, info: any) {
|
|
85
85
|
return writeACode(redis.utils.Databases.PW_RESETS, { userId, info })
|
|
@@ -87,9 +87,9 @@ export async function getResetPasswordCode(userId: string, info: any) {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Given a reset code this will lookup to redis, check if the code is valid and delete if required.
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @return
|
|
90
|
+
* @param resetCode The code provided via the email link.
|
|
91
|
+
* @param deleteCode If the code is used/finished with this will delete it - defaults to true.
|
|
92
|
+
* @return returns the user ID if it is found
|
|
93
93
|
*/
|
|
94
94
|
export async function checkResetPasswordCode(
|
|
95
95
|
resetCode: string,
|
|
@@ -104,9 +104,9 @@ export async function checkResetPasswordCode(
|
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Generates an invitation code and writes it to redis - which can later be checked for user creation.
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @return
|
|
107
|
+
* @param email the email address which the code is being sent to (for use later).
|
|
108
|
+
* @param info Information to be carried along with the invitation.
|
|
109
|
+
* @return returns the code that was stored to redis.
|
|
110
110
|
*/
|
|
111
111
|
export async function getInviteCode(email: string, info: any) {
|
|
112
112
|
return writeACode(redis.utils.Databases.INVITATIONS, { email, info })
|
|
@@ -114,9 +114,9 @@ export async function getInviteCode(email: string, info: any) {
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Checks that the provided invite code is valid - will return the email address of user that was invited.
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @return
|
|
117
|
+
* @param inviteCode the invite code that was provided as part of the link.
|
|
118
|
+
* @param deleteCode whether or not the code should be deleted after retrieval - defaults to true.
|
|
119
|
+
* @return If the code is valid then an email address will be returned.
|
|
120
120
|
*/
|
|
121
121
|
export async function checkInviteCode(
|
|
122
122
|
inviteCode: string,
|