@paroicms/server 1.41.0 → 1.41.1
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/dist/helpers/make-plugin-site-context.d.ts +1 -0
- package/dist/helpers/make-plugin-site-context.js +11 -1
- package/dist/helpers/make-plugin-site-context.js.map +1 -1
- package/dist/modules/public-api/mail/validate-recaptcha-response.d.ts +4 -1
- package/dist/modules/public-api/mail/validate-recaptcha-response.js +8 -20
- package/dist/modules/public-api/mail/validate-recaptcha-response.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { PluginSiteContext } from "@paroicms/plugin-lib";
|
|
2
2
|
import type { SiteContext } from "../site-context/site-context.types";
|
|
3
3
|
export default function makePluginSiteContext(siteContext: SiteContext): PluginSiteContext;
|
|
4
|
+
export declare function createValidateRecaptchaResponseForPlugin(siteContext: Pick<SiteContext, "fqdn">): (gRecaptchaResponse: string | undefined) => Promise<boolean>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createValidateRecaptchaResponseForPlugin = void 0;
|
|
3
4
|
const sendMail_helpers_1 = require("../common/mail/sendMail.helpers");
|
|
5
|
+
const context_1 = require("../context");
|
|
4
6
|
const load_fields_queries_1 = require("../modules/core/fields/load-fields.queries");
|
|
5
7
|
const validate_recaptcha_response_1 = require("../modules/public-api/mail/validate-recaptcha-response");
|
|
6
8
|
function makePluginSiteContext(siteContext) {
|
|
@@ -11,7 +13,7 @@ function makePluginSiteContext(siteContext) {
|
|
|
11
13
|
siteSchema: siteContext.siteSchema,
|
|
12
14
|
siteUrl: siteContext.siteUrl,
|
|
13
15
|
themeConf: siteContext.themeConf,
|
|
14
|
-
validateRecaptchaResponse: (
|
|
16
|
+
validateRecaptchaResponse: createValidateRecaptchaResponseForPlugin(siteContext),
|
|
15
17
|
getSiteFieldValue: async (options) => {
|
|
16
18
|
return await (0, load_fields_queries_1.getSiteFieldValue)(siteContext, options);
|
|
17
19
|
},
|
|
@@ -19,4 +21,12 @@ function makePluginSiteContext(siteContext) {
|
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
exports.default = makePluginSiteContext;
|
|
24
|
+
function createValidateRecaptchaResponseForPlugin(siteContext) {
|
|
25
|
+
if (!context_1.appConf.googleRecaptcha || context_1.appConf.googleRecaptcha.disabled) {
|
|
26
|
+
return () => Promise.resolve(true);
|
|
27
|
+
}
|
|
28
|
+
const { secretKey } = context_1.appConf.googleRecaptcha;
|
|
29
|
+
return (gRecaptchaResponse) => (0, validate_recaptcha_response_1.validateRecaptchaResponse)(siteContext, { gRecaptchaResponse, secretKey });
|
|
30
|
+
}
|
|
31
|
+
exports.createValidateRecaptchaResponseForPlugin = createValidateRecaptchaResponseForPlugin;
|
|
22
32
|
//# sourceMappingURL=make-plugin-site-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-plugin-site-context.js","sourceRoot":"","sources":["../../src/helpers/make-plugin-site-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"make-plugin-site-context.js","sourceRoot":"","sources":["../../src/helpers/make-plugin-site-context.ts"],"names":[],"mappings":";;;AACA,sEAA2D;AAC3D,wCAAqC;AACrC,oFAA+E;AAC/E,wGAAmG;AAGnG,SAAwB,qBAAqB,CAAC,WAAwB;IACpE,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,yBAAyB,EAAE,wCAAwC,CAAC,WAAW,CAAC;QAChF,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACnC,OAAO,MAAM,IAAA,uCAAiB,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,QAAQ,EAAR,2BAAQ;KACT,CAAC;AACJ,CAAC;AAdD,wCAcC;AACD,SAAgB,wCAAwC,CACtD,WAAsC;IAEtC,IAAI,CAAC,iBAAO,CAAC,eAAe,IAAI,iBAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;QACjE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,SAAS,EAAE,GAAG,iBAAO,CAAC,eAAe,CAAC;IAC9C,OAAO,CAAC,kBAAsC,EAAE,EAAE,CAChD,IAAA,uDAAyB,EAAC,WAAW,EAAE,EAAE,kBAAkB,EAAE,SAAS,EAAE,CAAC,CAAC;AAC9E,CAAC;AATD,4FASC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { SiteContext } from "../../../site-context/site-context.types";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function validateRecaptchaResponse(siteContext: Pick<SiteContext, "fqdn">, { gRecaptchaResponse, secretKey, }: {
|
|
3
|
+
gRecaptchaResponse: string | undefined;
|
|
4
|
+
secretKey: string;
|
|
5
|
+
}): Promise<boolean>;
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateRecaptchaResponse = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
|
|
6
|
-
function getValidateRecaptchaResponseCb(siteContext) {
|
|
7
|
-
if (!context_1.appConf.googleRecaptcha || context_1.appConf.googleRecaptcha.disabled)
|
|
8
|
-
return;
|
|
9
|
-
const googleRecaptcha = context_1.appConf.googleRecaptcha;
|
|
10
|
-
return (gRecaptchaResponse) => validateRecaptchaResponse(siteContext, {
|
|
11
|
-
gRecaptchaResponse,
|
|
12
|
-
googleRecaptchaPrivateKey: googleRecaptcha.siteKey,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
exports.getValidateRecaptchaResponseCb = getValidateRecaptchaResponseCb;
|
|
16
|
-
async function validateRecaptchaResponse(siteContext, { gRecaptchaResponse, googleRecaptchaPrivateKey, }) {
|
|
5
|
+
async function validateRecaptchaResponse(siteContext, { gRecaptchaResponse, secretKey, }) {
|
|
17
6
|
if (!gRecaptchaResponse)
|
|
18
7
|
throw new common_1.BadRequestException("Missing gRecaptchaResponse");
|
|
19
|
-
if (!
|
|
8
|
+
if (!secretKey) {
|
|
20
9
|
throw new Error("Invalid configuration, missing 'recaptchaPrivateKey'");
|
|
21
10
|
}
|
|
22
|
-
const url = `https://www.google.com/recaptcha/api/siteverify?secret=${
|
|
11
|
+
const url = `https://www.google.com/recaptcha/api/siteverify?secret=${secretKey}&response=${gRecaptchaResponse}`;
|
|
23
12
|
const response = await fetch(url, {
|
|
24
13
|
method: "post",
|
|
25
14
|
});
|
|
26
15
|
if (response.status < 200 || response.status >= 300) {
|
|
27
16
|
throw new Error("Failed to call the Google Recaptcha API");
|
|
28
17
|
}
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
throw new common_1.BadRequestException("invalid recaptcha response");
|
|
32
|
-
}
|
|
33
|
-
if (payload.hostname !== siteContext.fqdn) {
|
|
18
|
+
const result = (await response.json());
|
|
19
|
+
if (result.hostname !== siteContext.fqdn) {
|
|
34
20
|
throw new common_1.UnauthorizedException();
|
|
35
21
|
}
|
|
22
|
+
return result.success;
|
|
36
23
|
}
|
|
24
|
+
exports.validateRecaptchaResponse = validateRecaptchaResponse;
|
|
37
25
|
//# sourceMappingURL=validate-recaptcha-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-recaptcha-response.js","sourceRoot":"","sources":["../../../../src/modules/public-api/mail/validate-recaptcha-response.ts"],"names":[],"mappings":";;;AAAA,2CAA4E;
|
|
1
|
+
{"version":3,"file":"validate-recaptcha-response.js","sourceRoot":"","sources":["../../../../src/modules/public-api/mail/validate-recaptcha-response.ts"],"names":[],"mappings":";;;AAAA,2CAA4E;AAgBrE,KAAK,UAAU,yBAAyB,CAC7C,WAAsC,EACtC,EACE,kBAAkB,EAClB,SAAS,GAIV;IAED,IAAI,CAAC,kBAAkB;QAAE,MAAM,IAAI,4BAAmB,CAAC,4BAA4B,CAAC,CAAC;IACrF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,GAAG,GAAG,0DAA0D,SAAS,aAAa,kBAAkB,EAAE,CAAC;IACjH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAsC,CAAC;IAC5E,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,IAAI,8BAAqB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AA1BD,8DA0BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/server",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.1",
|
|
4
4
|
"description": "The ParoiCMS server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"@paroi/data-formatters-lib": "~0.3.0",
|
|
50
50
|
"@paroicms/anywhere-lib": "1.15.0",
|
|
51
51
|
"@paroicms/bo": "1.32.0",
|
|
52
|
-
"@paroicms/plugin-lib": "0.5.
|
|
52
|
+
"@paroicms/plugin-lib": "0.5.1",
|
|
53
53
|
"@paroicms/server-database-media-storage": "1.6.4",
|
|
54
|
-
"@paroicms/server-image-cache-engine": "1.9.
|
|
54
|
+
"@paroicms/server-image-cache-engine": "1.9.1",
|
|
55
55
|
"@paroicms/server-lib": "1.5.7",
|
|
56
56
|
"@paroicms/server-text-cache-system": "1.5.5",
|
|
57
57
|
"@paroicms/site-app": "1.8.0",
|