@waline/vercel 1.26.5 → 1.27.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/.eslintrc.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  globals:
2
2
  think: readonly
3
3
 
4
+ rules:
5
+ import/no-commonjs:
6
+ - off
7
+
4
8
  overrides:
5
9
  - files:
6
10
  - '__tests__/**/*.spec.js'
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/unbound-method */
2
- import { describe, expect, it } from 'vitest';
3
2
  import MarkdownIt from 'markdown-it';
3
+ import { describe, expect, it, vi } from 'vitest';
4
+
4
5
  import { katexPlugin } from '../src/service/markdown/katex';
5
- import { vi } from 'vitest';
6
6
 
7
7
  const markdownIt = MarkdownIt({ linkify: true }).use(katexPlugin, {
8
8
  output: 'mathml',
@@ -1,5 +1,6 @@
1
- import { describe, expect, it } from 'vitest';
2
1
  import MarkdownIt from 'markdown-it';
2
+ import { describe, expect, it } from 'vitest';
3
+
3
4
  import { mathjaxPlugin } from '../src/service/markdown/mathjax';
4
5
 
5
6
  const markdownIt = MarkdownIt({ linkify: true }).use(mathjaxPlugin);
@@ -1,5 +1,6 @@
1
- import { describe, expect, it } from 'vitest';
2
1
  import MarkdownIt from 'markdown-it';
2
+ import { describe, expect, it } from 'vitest';
3
+
3
4
  import { sanitize } from '../src/service/markdown/xss';
4
5
 
5
6
  const parser = (content) =>
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.26.4-deta",
3
+ "version": "1.26.5-deta",
4
4
  "description": "vercel server for waline comment system",
5
5
  "keywords": [
6
6
  "waline",
@@ -23,7 +23,7 @@
23
23
  "dy-node-ip2region": "1.0.1",
24
24
  "fast-csv": "4.3.6",
25
25
  "form-data": "4.0.0",
26
- "jsdom": "21.1.0",
26
+ "jsdom": "21.1.1",
27
27
  "jsonwebtoken": "9.0.0",
28
28
  "katex": "0.16.4",
29
29
  "leancloud-storage": "4.14.0",
@@ -47,7 +47,7 @@
47
47
  "think-mongo": "2.2.1",
48
48
  "think-router-rest": "1.0.5",
49
49
  "thinkjs": "3.2.14",
50
- "ua-parser-js": "1.0.33"
50
+ "ua-parser-js": "1.0.34"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=14"
@@ -6,7 +6,7 @@ const preventMessage = 'PREVENT_NEXT_PROCESS';
6
6
  const regionSearch = ip2region.create(process.env.IP2REGION_DB);
7
7
 
8
8
  const OS_VERSION_MAP = {
9
- 'Windows': {
9
+ Windows: {
10
10
  'NT 11.0': '11',
11
11
  },
12
12
  };
@@ -5,13 +5,13 @@ const DOMPurify = createDOMPurify(new JSDOM('').window);
5
5
 
6
6
  /**
7
7
  * Add a hook to make all links open a new window
8
- * and force their rel to be 'noreferrer noopener'
8
+ * and force their rel to be 'nofollow noreferrer noopener'
9
9
  */
10
10
  DOMPurify.addHook('afterSanitizeAttributes', function (node) {
11
11
  // set all elements owning target to target=_blank
12
12
  if ('target' in node && node.href && !node.href.startsWith('about:blank#')) {
13
13
  node.setAttribute('target', '_blank');
14
- node.setAttribute('rel', 'noreferrer noopener');
14
+ node.setAttribute('rel', 'nofollow noreferrer noopener');
15
15
  }
16
16
 
17
17
  // set non-HTML/MathML links to xlink:show=new
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const os = require('os');
2
2
  const path = require('path');
3
+
3
4
  const Application = require('thinkjs');
4
5
  const Loader = require('thinkjs/lib/loader');
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/vercel",
3
- "version": "1.26.5",
3
+ "version": "1.27.0",
4
4
  "description": "vercel server for waline comment system",
5
5
  "keywords": [
6
6
  "waline",
@@ -1,5 +1,6 @@
1
1
  const cors = require('@koa/cors');
2
2
  const routerREST = require('think-router-rest');
3
+
3
4
  const isDev = think.env === 'development';
4
5
  const isTcb = think.env === 'cloudbase';
5
6
  const isDeta = think.env === 'deta' || process.env.DETA_RUNTIME === 'true';
@@ -1,4 +1,5 @@
1
1
  const speakeasy = require('speakeasy');
2
+
2
3
  const BaseRest = require('../rest');
3
4
 
4
5
  module.exports = class extends BaseRest {
@@ -1,7 +1,8 @@
1
- const speakeasy = require('speakeasy');
2
1
  const jwt = require('jsonwebtoken');
3
- const helper = require('think-helper');
4
2
  const { PasswordHash } = require('phpass');
3
+ const speakeasy = require('speakeasy');
4
+ const helper = require('think-helper');
5
+
5
6
  const BaseRest = require('./rest');
6
7
 
7
8
  module.exports = class extends BaseRest {
@@ -1,4 +1,5 @@
1
1
  const jwt = require('jsonwebtoken');
2
+
2
3
  const BaseRest = require('../rest');
3
4
 
4
5
  module.exports = class extends BaseRest {
@@ -1,4 +1,5 @@
1
1
  const { PasswordHash } = require('phpass');
2
+
2
3
  const BaseRest = require('./rest');
3
4
 
4
5
  module.exports = class extends BaseRest {
@@ -1,4 +1,5 @@
1
1
  const nunjucks = require('nunjucks');
2
+
2
3
  const locales = require('../locales');
3
4
 
4
5
  module.exports = {
@@ -1,6 +1,7 @@
1
- const parser = require('ua-parser-js');
2
1
  const ip2region = require('dy-node-ip2region');
3
2
  const helper = require('think-helper');
3
+ const parser = require('ua-parser-js');
4
+
4
5
  const preventMessage = 'PREVENT_NEXT_PROCESS';
5
6
 
6
7
  const regionSearch = ip2region.create(process.env.IP2REGION_DB);
package/src/logic/base.js CHANGED
@@ -1,7 +1,8 @@
1
1
  const path = require('path');
2
2
  const qs = require('querystring');
3
- const fetch = require('node-fetch');
3
+
4
4
  const jwt = require('jsonwebtoken');
5
+ const fetch = require('node-fetch');
5
6
  const helper = require('think-helper');
6
7
 
7
8
  module.exports = class extends think.Logic {
@@ -1,4 +1,5 @@
1
1
  const Akismet = require('akismet');
2
+
2
3
  const DEFAULT_KEY = '70542d86693e';
3
4
 
4
5
  module.exports = function (comment, blog) {
@@ -1,5 +1,6 @@
1
1
  const nunjucks = require('nunjucks');
2
2
  const helper = require('think-helper');
3
+
3
4
  const { GRAVATAR_STR } = process.env;
4
5
 
5
6
  const env = new nunjucks.Environment();
@@ -2,9 +2,10 @@ const MarkdownIt = require('markdown-it');
2
2
  const emojiPlugin = require('markdown-it-emoji');
3
3
  const subPlugin = require('markdown-it-sub');
4
4
  const supPlugin = require('markdown-it-sup');
5
+
6
+ const { resolveHighlighter } = require('./highlight');
5
7
  const { katexPlugin } = require('./katex');
6
8
  const { mathjaxPlugin } = require('./mathjax');
7
- const { resolveHighlighter } = require('./highlight');
8
9
  const { sanitize } = require('./xss');
9
10
 
10
11
  const getMarkdownParser = () => {
@@ -1,6 +1,7 @@
1
1
  const katex = require('katex');
2
- const { escapeHtml } = require('./utils');
2
+
3
3
  const { inlineTex, blockTex } = require('./mathCommon');
4
+ const { escapeHtml } = require('./utils');
4
5
 
5
6
  // set KaTeX as the renderer for markdown-it-simplemath
6
7
  const katexInline = (tex, options) => {
@@ -1,12 +1,12 @@
1
- const { mathjax } = require('mathjax-full/js/mathjax');
2
- const { TeX } = require('mathjax-full/js/input/tex.js');
3
- const { SVG } = require('mathjax-full/js/output/svg.js');
4
1
  const { liteAdaptor } = require('mathjax-full/js/adaptors/liteAdaptor.js');
5
2
  const { RegisterHTMLHandler } = require('mathjax-full/js/handlers/html.js');
6
3
  const { AllPackages } = require('mathjax-full/js/input/tex/AllPackages.js');
4
+ const { TeX } = require('mathjax-full/js/input/tex.js');
5
+ const { mathjax } = require('mathjax-full/js/mathjax');
6
+ const { SVG } = require('mathjax-full/js/output/svg.js');
7
7
 
8
- const { escapeHtml } = require('./utils');
9
8
  const { inlineTex, blockTex } = require('./mathCommon');
9
+ const { escapeHtml } = require('./utils');
10
10
 
11
11
  // set MathJax as the renderer
12
12
  class MathToSvg {
@@ -1,8 +1,9 @@
1
+ const crypto = require('crypto');
2
+
1
3
  const FormData = require('form-data');
2
- const nodemailer = require('nodemailer');
3
4
  const fetch = require('node-fetch');
5
+ const nodemailer = require('nodemailer');
4
6
  const nunjucks = require('nunjucks');
5
- const crypto = require('crypto');
6
7
 
7
8
  module.exports = class extends think.Service {
8
9
  constructor(ctx) {
@@ -1,4 +1,5 @@
1
1
  const cloudbase = require('@cloudbase/node-sdk');
2
+
2
3
  const Base = require('./base');
3
4
 
4
5
  const { TCB_ENV, TCB_ID, TCB_KEY } = process.env;
@@ -1,5 +1,7 @@
1
- const { Deta } = require('deta');
2
1
  const { performance } = require('perf_hooks');
2
+
3
+ const { Deta } = require('deta');
4
+
3
5
  const Base = require('./base');
4
6
 
5
7
  module.exports = class extends Base {
@@ -1,6 +1,8 @@
1
+ const path = require('path');
2
+
1
3
  const { parseString, writeToString } = require('fast-csv');
2
4
  const fetch = require('node-fetch');
3
- const path = require('path');
5
+
4
6
  const Base = require('./base');
5
7
 
6
8
  const CSV_HEADERS = {
@@ -1,5 +1,7 @@
1
1
  const AV = require('leancloud-storage');
2
+
2
3
  const Base = require('./base');
4
+
3
5
  const { LEAN_ID, LEAN_KEY, LEAN_MASTER_KEY, LEAN_SERVER } = process.env;
4
6
 
5
7
  if (LEAN_ID && LEAN_KEY && LEAN_MASTER_KEY) {
@@ -1,4 +1,5 @@
1
1
  const { ObjectID: ObjectId } = require('think-mongo/lib/model');
2
+
2
3
  const Base = require('./base');
3
4
 
4
5
  module.exports = class extends Base {
package/vanilla.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+
2
3
  const Application = require('thinkjs');
3
4
 
4
5
  const instance = new Application({
package/build/build.js DELETED
@@ -1,69 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const blackList = ['think-model-sqlite'];
5
- const pkg = require(path.join(__dirname, '../package.json'));
6
-
7
- // pkg.name = '@waline/deta';
8
-
9
- const dist = path.join(__dirname, '../dist');
10
-
11
- function readFileRecursive(dir) {
12
- const files = fs.readdirSync(dir);
13
- const ret = [];
14
-
15
- for (let i = 0; i < files.length; i++) {
16
- const filePath = path.join(dir, files[i]);
17
- const fileInfo = fs.lstatSync(filePath);
18
-
19
- if (fileInfo.isDirectory()) {
20
- ret.push(...readFileRecursive(filePath));
21
- } else {
22
- ret.push(fs.readFileSync(filePath, 'utf-8'));
23
- }
24
- }
25
-
26
- return ret;
27
- }
28
-
29
- function findDeps(text) {
30
- const reg = /require\(\'([^.']+)\'\)/g;
31
- const matches = text.matchAll(reg);
32
- const deps = Array.from(matches, ([_, moduleName]) => {
33
- if (moduleName.includes('/') && !moduleName.startsWith('@')) {
34
- return moduleName.split('/')[0];
35
- }
36
-
37
- return moduleName;
38
- });
39
-
40
- return deps;
41
- }
42
-
43
- function main() {
44
- const codes = readFileRecursive(path.join(dist, 'src'));
45
- const deps = [];
46
-
47
- for (const code of codes) {
48
- const codeDeps = findDeps(code);
49
-
50
- deps.push(...codeDeps);
51
- }
52
-
53
- for (let dep in pkg.dependencies) {
54
- const exist = deps.includes(dep);
55
- const isBlack = blackList.includes(dep);
56
-
57
- if (!exist || isBlack) {
58
- delete pkg.dependencies[dep];
59
- }
60
- }
61
-
62
- fs.writeFileSync(
63
- path.join(dist, 'package.json'),
64
- JSON.stringify(pkg, null, '\t'),
65
- 'utf-8'
66
- );
67
- }
68
-
69
- main();
package/build/deta.sh DELETED
File without changes