@blocklet/uploader-server 0.2.5 → 0.2.7

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/es/utils.js CHANGED
@@ -14,6 +14,7 @@ import { existsSync, readdirSync, renameSync, statSync, unlinkSync, createReadSt
14
14
  import { join } from "path";
15
15
  import ExifTransformer from "exif-be-gone";
16
16
  export let logger = console;
17
+ const isProduction = process.env.NODE_ENV === "production" || process.env.ABT_NODE_SERVICE_ENV === "production";
17
18
  if (process.env.BLOCKLET_LOG_DIR) {
18
19
  try {
19
20
  const initLogger = require("@blocklet/logger");
@@ -41,11 +42,19 @@ export async function getTrustedDomainsCache({
41
42
  return trustedDomainsCache.domains;
42
43
  }
43
44
  }
44
- trustedDomainsCache.domains = await axios.get(joinUrl(appUrl, "/.well-known/service/api/federated/getTrustedDomains")).then((res) => res.data);
45
- trustedDomainsCache.timestamp = now;
45
+ try {
46
+ if (!trustedDomainsCache?.domains?.length) {
47
+ trustedDomainsCache.domains = await axios.get(joinUrl(appUrl, "/.well-known/service/api/federated/getTrustedDomains")).then((res) => res.data);
48
+ trustedDomainsCache.timestamp = now;
49
+ }
50
+ } catch (error) {
51
+ }
46
52
  return trustedDomainsCache.domains;
47
53
  }
48
54
  export async function checkTrustedReferer(req, res, next) {
55
+ if (!isProduction) {
56
+ return next?.();
57
+ }
49
58
  if (isbot(req.get("user-agent"))) {
50
59
  return next?.();
51
60
  }
package/lib/utils.js CHANGED
@@ -34,6 +34,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
34
34
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
35
35
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
36
36
  let logger = exports.logger = console;
37
+ const isProduction = process.env.NODE_ENV === "production" || process.env.ABT_NODE_SERVICE_ENV === "production";
37
38
  if (process.env.BLOCKLET_LOG_DIR) {
38
39
  try {
39
40
  const initLogger = require("@blocklet/logger");
@@ -60,11 +61,18 @@ async function getTrustedDomainsCache({
60
61
  return trustedDomainsCache.domains;
61
62
  }
62
63
  }
63
- trustedDomainsCache.domains = await _axios.default.get((0, _urlJoin.default)(appUrl, "/.well-known/service/api/federated/getTrustedDomains")).then(res => res.data);
64
- trustedDomainsCache.timestamp = now;
64
+ try {
65
+ if (!trustedDomainsCache?.domains?.length) {
66
+ trustedDomainsCache.domains = await _axios.default.get((0, _urlJoin.default)(appUrl, "/.well-known/service/api/federated/getTrustedDomains")).then(res => res.data);
67
+ trustedDomainsCache.timestamp = now;
68
+ }
69
+ } catch (error) {}
65
70
  return trustedDomainsCache.domains;
66
71
  }
67
72
  async function checkTrustedReferer(req, res, next) {
73
+ if (!isProduction) {
74
+ return next?.();
75
+ }
68
76
  if ((0, _isbot.isbot)(req.get("user-agent"))) {
69
77
  return next?.();
70
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/uploader-server",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "blocklet upload server",
5
5
  "publishConfig": {
6
6
  "access": "public"