@nocobase/plugin-workflow-mailer 2.3.0-beta.13 → 2.3.0-beta.15

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.
Files changed (173) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/node_modules/joi/package.json +1 -1
  3. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.d.ts +59 -0
  4. package/dist/node_modules/nodemailer/dist/cjs/addressparser/index.js +790 -0
  5. package/dist/node_modules/nodemailer/dist/cjs/base64/index.d.ts +36 -0
  6. package/dist/node_modules/nodemailer/dist/cjs/base64/index.js +119 -0
  7. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.d.ts +52 -0
  8. package/dist/node_modules/nodemailer/dist/cjs/dkim/index.js +228 -0
  9. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.d.ts +48 -0
  10. package/dist/node_modules/nodemailer/dist/cjs/dkim/message-parser.js +180 -0
  11. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.d.ts +36 -0
  12. package/dist/node_modules/nodemailer/dist/cjs/dkim/relaxed-body.js +148 -0
  13. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.d.ts +52 -0
  14. package/dist/node_modules/nodemailer/dist/cjs/dkim/sign.js +165 -0
  15. package/dist/node_modules/nodemailer/dist/cjs/errors.d.ts +96 -0
  16. package/dist/node_modules/nodemailer/dist/cjs/errors.js +70 -0
  17. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.d.ts +107 -0
  18. package/dist/node_modules/nodemailer/dist/cjs/fetch/cookies.js +282 -0
  19. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.d.ts +65 -0
  20. package/dist/node_modules/nodemailer/dist/cjs/fetch/index.js +384 -0
  21. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.d.ts +64 -0
  22. package/dist/node_modules/nodemailer/dist/cjs/json-transport/index.js +99 -0
  23. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.d.ts +174 -0
  24. package/dist/node_modules/nodemailer/dist/cjs/mail-composer/index.js +613 -0
  25. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.d.ts +237 -0
  26. package/dist/node_modules/nodemailer/dist/cjs/mailer/index.js +415 -0
  27. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.d.ts +97 -0
  28. package/dist/node_modules/nodemailer/dist/cjs/mailer/mail-message.js +342 -0
  29. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.d.ts +161 -0
  30. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/index.js +787 -0
  31. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.d.ts +2 -0
  32. package/dist/node_modules/nodemailer/dist/cjs/mime-funcs/mime-types.js +2103 -0
  33. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.d.ts +333 -0
  34. package/dist/node_modules/nodemailer/dist/cjs/mime-node/index.js +1493 -0
  35. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.d.ts +5 -0
  36. package/dist/node_modules/nodemailer/dist/cjs/mime-node/last-newline.js +32 -0
  37. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.d.ts +9 -0
  38. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-unix.js +40 -0
  39. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.d.ts +10 -0
  40. package/dist/node_modules/nodemailer/dist/cjs/mime-node/le-windows.js +47 -0
  41. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.d.ts +124 -0
  42. package/dist/node_modules/nodemailer/dist/cjs/nodemailer.js +1 -0
  43. package/dist/node_modules/nodemailer/dist/cjs/package-info.d.ts +3 -0
  44. package/dist/node_modules/nodemailer/dist/cjs/package-info.js +7 -0
  45. package/dist/node_modules/nodemailer/dist/cjs/package.json +3 -0
  46. package/dist/node_modules/nodemailer/dist/cjs/punycode/index.d.ts +73 -0
  47. package/dist/node_modules/nodemailer/{lib → dist/cjs}/punycode/index.js +62 -111
  48. package/dist/node_modules/nodemailer/dist/cjs/qp/index.d.ts +32 -0
  49. package/dist/node_modules/nodemailer/dist/cjs/qp/index.js +207 -0
  50. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.d.ts +69 -0
  51. package/dist/node_modules/nodemailer/dist/cjs/sendmail-transport/index.js +210 -0
  52. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.d.ts +112 -0
  53. package/dist/node_modules/nodemailer/dist/cjs/ses-transport/index.js +252 -0
  54. package/dist/node_modules/nodemailer/dist/cjs/shared/index.d.ts +260 -0
  55. package/dist/node_modules/nodemailer/dist/cjs/shared/index.js +680 -0
  56. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.d.ts +23 -0
  57. package/dist/node_modules/nodemailer/dist/cjs/shared/objects.js +43 -0
  58. package/dist/node_modules/nodemailer/dist/cjs/shared/url.d.ts +21 -0
  59. package/dist/node_modules/nodemailer/dist/cjs/shared/url.js +255 -0
  60. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.d.ts +15 -0
  61. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/data-stream.js +108 -0
  62. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.d.ts +47 -0
  63. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/http-proxy-client.js +189 -0
  64. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.d.ts +416 -0
  65. package/dist/node_modules/nodemailer/dist/cjs/smtp-connection/index.js +1837 -0
  66. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.d.ts +133 -0
  67. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/index.js +569 -0
  68. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.d.ts +62 -0
  69. package/dist/node_modules/nodemailer/dist/cjs/smtp-pool/pool-resource.js +257 -0
  70. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.d.ts +156 -0
  71. package/dist/node_modules/nodemailer/dist/cjs/smtp-transport/index.js +371 -0
  72. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.d.ts +65 -0
  73. package/dist/node_modules/nodemailer/dist/cjs/stream-transport/index.js +146 -0
  74. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.d.ts +35 -0
  75. package/dist/node_modules/nodemailer/dist/cjs/well-known/index.js +41 -0
  76. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.d.ts +2 -0
  77. package/dist/node_modules/nodemailer/dist/cjs/well-known/services.js +674 -0
  78. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.d.ts +201 -0
  79. package/dist/node_modules/nodemailer/dist/cjs/xoauth2/index.js +426 -0
  80. package/dist/node_modules/nodemailer/dist/esm/addressparser/index.d.ts +59 -0
  81. package/dist/node_modules/nodemailer/{lib → dist/esm}/addressparser/index.js +361 -131
  82. package/dist/node_modules/nodemailer/dist/esm/base64/index.d.ts +36 -0
  83. package/dist/node_modules/nodemailer/{lib → dist/esm}/base64/index.js +31 -56
  84. package/dist/node_modules/nodemailer/dist/esm/dkim/index.d.ts +52 -0
  85. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/index.js +49 -78
  86. package/dist/node_modules/nodemailer/dist/esm/dkim/message-parser.d.ts +48 -0
  87. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/message-parser.js +64 -42
  88. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.d.ts +36 -0
  89. package/dist/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js +141 -0
  90. package/dist/node_modules/nodemailer/dist/esm/dkim/sign.d.ts +52 -0
  91. package/dist/node_modules/nodemailer/{lib → dist/esm}/dkim/sign.js +50 -46
  92. package/dist/node_modules/nodemailer/dist/esm/errors.d.ts +96 -0
  93. package/dist/node_modules/nodemailer/{lib → dist/esm}/errors.js +26 -18
  94. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.d.ts +107 -0
  95. package/dist/node_modules/nodemailer/dist/esm/fetch/cookies.js +242 -0
  96. package/dist/node_modules/nodemailer/dist/esm/fetch/index.d.ts +65 -0
  97. package/dist/node_modules/nodemailer/{lib → dist/esm}/fetch/index.js +80 -147
  98. package/dist/node_modules/nodemailer/dist/esm/json-transport/index.d.ts +64 -0
  99. package/dist/node_modules/nodemailer/{lib → dist/esm}/json-transport/index.js +19 -39
  100. package/dist/node_modules/nodemailer/dist/esm/mail-composer/index.d.ts +174 -0
  101. package/dist/node_modules/nodemailer/{lib → dist/esm}/mail-composer/index.js +199 -265
  102. package/dist/node_modules/nodemailer/dist/esm/mailer/index.d.ts +237 -0
  103. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/index.js +128 -234
  104. package/dist/node_modules/nodemailer/dist/esm/mailer/mail-message.d.ts +97 -0
  105. package/dist/node_modules/nodemailer/{lib → dist/esm}/mailer/mail-message.js +62 -114
  106. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.d.ts +161 -0
  107. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/index.js +738 -0
  108. package/dist/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.d.ts +2 -0
  109. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-funcs/mime-types.js +29 -42
  110. package/dist/node_modules/nodemailer/dist/esm/mime-node/index.d.ts +333 -0
  111. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/index.js +259 -372
  112. package/dist/node_modules/nodemailer/dist/esm/mime-node/last-newline.d.ts +5 -0
  113. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/last-newline.js +4 -10
  114. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-unix.d.ts +9 -0
  115. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-unix.js +6 -11
  116. package/dist/node_modules/nodemailer/dist/esm/mime-node/le-windows.d.ts +10 -0
  117. package/dist/node_modules/nodemailer/{lib → dist/esm}/mime-node/le-windows.js +6 -13
  118. package/dist/node_modules/nodemailer/dist/esm/nodemailer.d.ts +124 -0
  119. package/dist/node_modules/nodemailer/dist/esm/nodemailer.js +166 -0
  120. package/dist/node_modules/nodemailer/dist/esm/package-info.d.ts +3 -0
  121. package/dist/node_modules/nodemailer/dist/esm/package-info.js +4 -0
  122. package/dist/node_modules/nodemailer/dist/esm/package.json +3 -0
  123. package/dist/node_modules/nodemailer/dist/esm/punycode/index.d.ts +73 -0
  124. package/dist/node_modules/nodemailer/dist/esm/punycode/index.js +405 -0
  125. package/dist/node_modules/nodemailer/dist/esm/qp/index.d.ts +32 -0
  126. package/dist/node_modules/nodemailer/{lib → dist/esm}/qp/index.js +38 -67
  127. package/dist/node_modules/nodemailer/dist/esm/sendmail-transport/index.d.ts +69 -0
  128. package/dist/node_modules/nodemailer/{lib → dist/esm}/sendmail-transport/index.js +51 -101
  129. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.d.ts +112 -0
  130. package/dist/node_modules/nodemailer/dist/esm/ses-transport/index.js +212 -0
  131. package/dist/node_modules/nodemailer/dist/esm/shared/index.d.ts +260 -0
  132. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/index.js +156 -272
  133. package/dist/node_modules/nodemailer/dist/esm/shared/objects.d.ts +23 -0
  134. package/dist/node_modules/nodemailer/{lib → dist/esm}/shared/objects.js +13 -17
  135. package/dist/node_modules/nodemailer/dist/esm/shared/url.d.ts +21 -0
  136. package/dist/node_modules/nodemailer/dist/esm/shared/url.js +214 -0
  137. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.d.ts +15 -0
  138. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js +103 -0
  139. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.d.ts +47 -0
  140. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/http-proxy-client.js +49 -74
  141. package/dist/node_modules/nodemailer/dist/esm/smtp-connection/index.d.ts +416 -0
  142. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-connection/index.js +574 -794
  143. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/index.d.ts +133 -0
  144. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/index.js +172 -284
  145. package/dist/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.d.ts +62 -0
  146. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-pool/pool-resource.js +57 -97
  147. package/dist/node_modules/nodemailer/dist/esm/smtp-transport/index.d.ts +156 -0
  148. package/dist/node_modules/nodemailer/{lib → dist/esm}/smtp-transport/index.js +81 -179
  149. package/dist/node_modules/nodemailer/dist/esm/stream-transport/index.d.ts +65 -0
  150. package/dist/node_modules/nodemailer/{lib → dist/esm}/stream-transport/index.js +36 -74
  151. package/dist/node_modules/nodemailer/dist/esm/well-known/index.d.ts +35 -0
  152. package/dist/node_modules/nodemailer/{lib → dist/esm}/well-known/index.js +5 -16
  153. package/dist/node_modules/nodemailer/dist/esm/well-known/services.d.ts +2 -0
  154. package/dist/node_modules/nodemailer/dist/esm/well-known/services.js +671 -0
  155. package/dist/node_modules/nodemailer/dist/esm/xoauth2/index.d.ts +201 -0
  156. package/dist/node_modules/nodemailer/{lib → dist/esm}/xoauth2/index.js +125 -187
  157. package/dist/node_modules/nodemailer/{lib → dist}/well-known/services.json +9 -2
  158. package/dist/node_modules/nodemailer/package.json +1 -1
  159. package/package.json +3 -3
  160. package/dist/node_modules/nodemailer/.gitattributes +0 -6
  161. package/dist/node_modules/nodemailer/.ncurc.js +0 -9
  162. package/dist/node_modules/nodemailer/.prettierignore +0 -8
  163. package/dist/node_modules/nodemailer/.prettierrc +0 -12
  164. package/dist/node_modules/nodemailer/.prettierrc.js +0 -10
  165. package/dist/node_modules/nodemailer/.release-please-config.json +0 -9
  166. package/dist/node_modules/nodemailer/eslint.config.js +0 -88
  167. package/dist/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
  168. package/dist/node_modules/nodemailer/lib/fetch/cookies.js +0 -276
  169. package/dist/node_modules/nodemailer/lib/mime-funcs/index.js +0 -671
  170. package/dist/node_modules/nodemailer/lib/nodemailer.js +0 -1
  171. package/dist/node_modules/nodemailer/lib/ses-transport/index.js +0 -266
  172. package/dist/node_modules/nodemailer/lib/shared/url.js +0 -151
  173. package/dist/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -105
@@ -1,12 +0,0 @@
1
- {
2
- "printWidth": 140,
3
- "tabWidth": 4,
4
- "useTabs": false,
5
- "semi": true,
6
- "singleQuote": true,
7
- "quoteProps": "as-needed",
8
- "trailingComma": "none",
9
- "bracketSpacing": true,
10
- "arrowParens": "avoid",
11
- "endOfLine": "lf"
12
- }
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- printWidth: 160,
5
- tabWidth: 4,
6
- singleQuote: true,
7
- endOfLine: 'lf',
8
- trailingComma: 'none',
9
- arrowParens: 'avoid'
10
- };
@@ -1,9 +0,0 @@
1
- {
2
- "packages": {
3
- ".": {
4
- "release-type": "node",
5
- "package-name": "nodemailer",
6
- "pull-request-title-pattern": "chore${scope}: release ${version} [skip-ci]"
7
- }
8
- }
9
- }
@@ -1,88 +0,0 @@
1
- 'use strict';
2
-
3
- const globals = require('globals');
4
-
5
- module.exports = [
6
- {
7
- ignores: ['node_modules/**', 'coverage/**', 'dist/**', 'build/**', '.nyc_output/**']
8
- },
9
- {
10
- files: ['**/*.js'],
11
- languageOptions: {
12
- ecmaVersion: 2017,
13
- sourceType: 'script',
14
- globals: Object.assign({}, globals.node, globals.es2017, {
15
- it: true,
16
- describe: true,
17
- beforeEach: true,
18
- afterEach: true
19
- })
20
- },
21
- rules: {
22
- // Error detection
23
- 'for-direction': 'error',
24
- 'no-await-in-loop': 'error',
25
- 'no-div-regex': 'error',
26
- eqeqeq: 'error',
27
- 'dot-notation': 'error',
28
- curly: 'error',
29
- 'no-fallthrough': 'error',
30
- 'no-unused-expressions': [
31
- 'error',
32
- {
33
- allowShortCircuit: true
34
- }
35
- ],
36
- 'no-unused-vars': [
37
- 'error',
38
- {
39
- varsIgnorePattern: '^_',
40
- argsIgnorePattern: '^_',
41
- caughtErrorsIgnorePattern: '^_'
42
- }
43
- ],
44
- 'handle-callback-err': 'error',
45
- 'no-new': 'error',
46
- 'new-cap': 'error',
47
- 'no-eval': 'error',
48
- 'no-invalid-this': 'error',
49
- radix: ['error', 'always'],
50
- 'no-use-before-define': ['error', 'nofunc'],
51
- 'callback-return': ['error', ['callback', 'cb', 'done']],
52
- 'no-regex-spaces': 'error',
53
- 'no-empty': 'error',
54
- 'no-duplicate-case': 'error',
55
- 'no-empty-character-class': 'error',
56
- 'no-redeclare': 'off', // Disabled per project preference
57
- 'block-scoped-var': 'error',
58
- 'no-sequences': 'error',
59
- 'no-throw-literal': 'error',
60
- 'no-useless-call': 'error',
61
- 'no-useless-concat': 'error',
62
- 'no-void': 'error',
63
- yoda: 'error',
64
- 'no-undef': 'error',
65
- 'global-require': 'error',
66
- 'no-var': 'error',
67
- 'no-bitwise': 'error',
68
- 'no-lonely-if': 'error',
69
- 'no-mixed-spaces-and-tabs': 'error',
70
- 'arrow-body-style': ['error', 'as-needed'],
71
- 'arrow-parens': ['error', 'as-needed'],
72
- 'prefer-arrow-callback': 'error',
73
- 'object-shorthand': 'error',
74
- 'prefer-spread': 'error',
75
- 'no-prototype-builtins': 'off', // Disabled per project preference
76
- strict: ['error', 'global'],
77
-
78
- // Disable all formatting rules (handled by Prettier)
79
- indent: 'off',
80
- quotes: 'off',
81
- 'linebreak-style': 'off',
82
- semi: 'off',
83
- 'quote-props': 'off',
84
- 'comma-dangle': 'off',
85
- 'comma-style': 'off'
86
- }
87
- }
88
- ];
@@ -1,154 +0,0 @@
1
- 'use strict';
2
-
3
- // streams through a message body and calculates relaxed body hash
4
-
5
- const { Transform } = require('stream');
6
- const crypto = require('crypto');
7
-
8
- class RelaxedBody extends Transform {
9
- constructor(options) {
10
- super();
11
- options = options || {};
12
- this.chunkBuffer = [];
13
- this.chunkBufferLen = 0;
14
- this.bodyHash = crypto.createHash(options.hashAlgo || 'sha256');
15
- this.remainder = '';
16
- this.byteLength = 0;
17
-
18
- this.debug = options.debug;
19
- this._debugBody = options.debug ? [] : false;
20
- }
21
-
22
- updateHash(chunk) {
23
- let bodyStr;
24
-
25
- // find next remainder
26
- let nextRemainder = '';
27
-
28
- // This crux finds and removes the spaces from the last line and the newline characters after the last non-empty line
29
- // If we get another chunk that does not match this description then we can restore the previously processed data
30
- let state = 'file';
31
- for (let i = chunk.length - 1; i >= 0; i--) {
32
- const c = chunk[i];
33
-
34
- if (state === 'file' && (c === 0x0a || c === 0x0d)) {
35
- // do nothing, found \n or \r at the end of chunk, stil end of file
36
- } else if (state === 'file' && (c === 0x09 || c === 0x20)) {
37
- // switch to line ending mode, this is the last non-empty line
38
- state = 'line';
39
- } else if (state === 'line' && (c === 0x09 || c === 0x20)) {
40
- // do nothing, found ' ' or \t at the end of line, keep processing the last non-empty line
41
- } else if (state === 'file' || state === 'line') {
42
- // non line/file ending character found, switch to body mode
43
- state = 'body';
44
- if (i === chunk.length - 1) {
45
- // final char is not part of line end or file end, so do nothing
46
- break;
47
- }
48
- }
49
-
50
- if (i === 0) {
51
- // reached to the beginning of the chunk, check if it is still about the ending
52
- // and if the remainder also matches
53
- if (
54
- (state === 'file' && (!this.remainder || /[\r\n]$/.test(this.remainder))) ||
55
- (state === 'line' && (!this.remainder || /[ \t]$/.test(this.remainder)))
56
- ) {
57
- // keep everything
58
- this.remainder += chunk.toString('binary');
59
- return;
60
- } else if (state === 'line' || state === 'file') {
61
- // process existing remainder as normal line but store the current chunk
62
- nextRemainder = chunk.toString('binary');
63
- chunk = false;
64
- break;
65
- }
66
- }
67
-
68
- if (state !== 'body') {
69
- continue;
70
- }
71
-
72
- // reached first non ending byte
73
- nextRemainder = chunk.slice(i + 1).toString('binary');
74
- chunk = chunk.slice(0, i + 1);
75
- break;
76
- }
77
-
78
- let needsFixing = !!this.remainder;
79
- if (chunk && !needsFixing) {
80
- // check if we even need to change anything
81
- for (let i = 0, len = chunk.length; i < len; i++) {
82
- if (i && chunk[i] === 0x0a && chunk[i - 1] !== 0x0d) {
83
- // missing \r before \n
84
- needsFixing = true;
85
- break;
86
- } else if (i && chunk[i] === 0x0d && chunk[i - 1] === 0x20) {
87
- // trailing WSP found
88
- needsFixing = true;
89
- break;
90
- } else if (i && chunk[i] === 0x20 && chunk[i - 1] === 0x20) {
91
- // multiple spaces found, needs to be replaced with just one
92
- needsFixing = true;
93
- break;
94
- } else if (chunk[i] === 0x09) {
95
- // TAB found, needs to be replaced with a space
96
- needsFixing = true;
97
- break;
98
- }
99
- }
100
- }
101
-
102
- if (needsFixing) {
103
- bodyStr = this.remainder + (chunk ? chunk.toString('binary') : '');
104
- this.remainder = nextRemainder;
105
- bodyStr = bodyStr
106
- .replace(/\r?\n/g, '\n') // use js line endings
107
- .replace(/[ \t]*$/gm, '') // remove line endings, rtrim
108
- .replace(/[ \t]+/gm, ' ') // single spaces
109
- .replace(/\n/g, '\r\n'); // restore rfc822 line endings
110
- chunk = Buffer.from(bodyStr, 'binary');
111
- } else if (nextRemainder) {
112
- this.remainder = nextRemainder;
113
- }
114
-
115
- if (this.debug) {
116
- this._debugBody.push(chunk);
117
- }
118
- this.bodyHash.update(chunk);
119
- }
120
-
121
- _transform(chunk, encoding, callback) {
122
- if (!chunk || !chunk.length) {
123
- return callback();
124
- }
125
-
126
- if (typeof chunk === 'string') {
127
- chunk = Buffer.from(chunk, encoding);
128
- }
129
-
130
- this.updateHash(chunk);
131
-
132
- this.byteLength += chunk.length;
133
- this.push(chunk);
134
- callback();
135
- }
136
-
137
- _flush(callback) {
138
- // generate final hash and emit it
139
- if (/[\r\n]$/.test(this.remainder) && this.byteLength > 2) {
140
- // add terminating line end
141
- this.bodyHash.update(Buffer.from('\r\n'));
142
- }
143
- if (!this.byteLength) {
144
- // emit empty line buffer to keep the stream flowing
145
- this.push(Buffer.from('\r\n'));
146
- // this.bodyHash.update(Buffer.from('\r\n'));
147
- }
148
-
149
- this.emit('hash', this.bodyHash.digest('base64'), this.debug ? Buffer.concat(this._debugBody) : false);
150
- callback();
151
- }
152
- }
153
-
154
- module.exports = RelaxedBody;
@@ -1,276 +0,0 @@
1
- 'use strict';
2
-
3
- // module to handle cookies
4
-
5
- const urllib = require('../shared/url');
6
-
7
- const SESSION_TIMEOUT = 1800; // 30 min
8
-
9
- /**
10
- * Creates a biskviit cookie jar for managing cookie values in memory
11
- *
12
- * @constructor
13
- * @param {Object} [options] Optional options object
14
- */
15
- class Cookies {
16
- constructor(options) {
17
- this.options = options || {};
18
- this.cookies = [];
19
- }
20
-
21
- /**
22
- * Stores a cookie string to the cookie storage
23
- *
24
- * @param {String} cookieStr Value from the 'Set-Cookie:' header
25
- * @param {String} url Current URL
26
- */
27
- set(cookieStr, url) {
28
- const urlparts = urllib.parse(url || '');
29
- const cookie = this.parse(cookieStr);
30
- let domain;
31
-
32
- if (cookie.domain) {
33
- domain = cookie.domain.replace(/^\./, '');
34
-
35
- // do not allow cross origin cookies
36
- if (
37
- // can't be valid if the requested domain is shorter than current hostname
38
- urlparts.hostname.length < domain.length ||
39
- // prefix domains with dot to be sure that partial matches are not used
40
- ('.' + urlparts.hostname).substr(-domain.length + 1) !== '.' + domain
41
- ) {
42
- cookie.domain = urlparts.hostname;
43
- }
44
- } else {
45
- cookie.domain = urlparts.hostname;
46
- }
47
-
48
- if (!cookie.path) {
49
- cookie.path = this.getPath(urlparts.pathname);
50
- }
51
-
52
- // if no expire date, then use sessionTimeout value
53
- if (!cookie.expires) {
54
- cookie.expires = new Date(Date.now() + (Number(this.options.sessionTimeout || SESSION_TIMEOUT) || SESSION_TIMEOUT) * 1000);
55
- }
56
-
57
- return this.add(cookie);
58
- }
59
-
60
- /**
61
- * Returns cookie string for the 'Cookie:' header.
62
- *
63
- * @param {String} url URL to check for
64
- * @returns {String} Cookie header or empty string if no matches were found
65
- */
66
- get(url) {
67
- return this.list(url)
68
- .map(cookie => cookie.name + '=' + cookie.value)
69
- .join('; ');
70
- }
71
-
72
- /**
73
- * Lists all valied cookie objects for the specified URL
74
- *
75
- * @param {String} url URL to check for
76
- * @returns {Array} An array of cookie objects
77
- */
78
- list(url) {
79
- const result = [];
80
-
81
- for (let i = this.cookies.length - 1; i >= 0; i--) {
82
- const cookie = this.cookies[i];
83
-
84
- if (this.isExpired(cookie)) {
85
- this.cookies.splice(i, 1);
86
- continue;
87
- }
88
-
89
- if (this.match(cookie, url)) {
90
- result.unshift(cookie);
91
- }
92
- }
93
-
94
- return result;
95
- }
96
-
97
- /**
98
- * Parses cookie string from the 'Set-Cookie:' header
99
- *
100
- * @param {String} cookieStr String from the 'Set-Cookie:' header
101
- * @returns {Object} Cookie object
102
- */
103
- parse(cookieStr) {
104
- const cookie = {};
105
-
106
- (cookieStr || '')
107
- .toString()
108
- .split(';')
109
- .forEach(cookiePart => {
110
- const valueParts = cookiePart.split('=');
111
- const key = valueParts.shift().trim().toLowerCase();
112
- let value = valueParts.join('=').trim();
113
- let domain;
114
-
115
- if (!key) {
116
- // skip empty parts
117
- return;
118
- }
119
-
120
- switch (key) {
121
- case 'expires':
122
- value = new Date(value);
123
- // ignore date if can not parse it
124
- if (value.toString() !== 'Invalid Date') {
125
- cookie.expires = value;
126
- }
127
- break;
128
-
129
- case 'path':
130
- cookie.path = value;
131
- break;
132
-
133
- case 'domain':
134
- domain = value.toLowerCase();
135
- if (domain.length && domain.charAt(0) !== '.') {
136
- domain = '.' + domain; // ensure preceeding dot for user set domains
137
- }
138
- cookie.domain = domain;
139
- break;
140
-
141
- case 'max-age':
142
- cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
143
- break;
144
-
145
- case 'secure':
146
- cookie.secure = true;
147
- break;
148
-
149
- case 'httponly':
150
- cookie.httponly = true;
151
- break;
152
-
153
- default:
154
- if (!cookie.name) {
155
- cookie.name = key;
156
- cookie.value = value;
157
- }
158
- }
159
- });
160
-
161
- return cookie;
162
- }
163
-
164
- /**
165
- * Checks if a cookie object is valid for a specified URL
166
- *
167
- * @param {Object} cookie Cookie object
168
- * @param {String} url URL to check for
169
- * @returns {Boolean} true if cookie is valid for specifiec URL
170
- */
171
- match(cookie, url) {
172
- const urlparts = urllib.parse(url || '');
173
-
174
- // check if hostname matches
175
- // .foo.com also matches subdomains, foo.com does not
176
- if (
177
- urlparts.hostname !== cookie.domain &&
178
- (cookie.domain.charAt(0) !== '.' || ('.' + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)
179
- ) {
180
- return false;
181
- }
182
-
183
- // check if path matches
184
- const path = this.getPath(urlparts.pathname);
185
- if (path.substr(0, cookie.path.length) !== cookie.path) {
186
- return false;
187
- }
188
-
189
- // check secure argument
190
- if (cookie.secure && urlparts.protocol !== 'https:') {
191
- return false;
192
- }
193
-
194
- return true;
195
- }
196
-
197
- /**
198
- * Adds (or updates/removes if needed) a cookie object to the cookie storage
199
- *
200
- * @param {Object} cookie Cookie value to be stored
201
- */
202
- add(cookie) {
203
- // nothing to do here
204
- if (!cookie || !cookie.name) {
205
- return false;
206
- }
207
-
208
- // overwrite if has same params
209
- for (let i = 0, len = this.cookies.length; i < len; i++) {
210
- if (this.compare(this.cookies[i], cookie)) {
211
- // check if the cookie needs to be removed instead
212
- if (this.isExpired(cookie)) {
213
- this.cookies.splice(i, 1); // remove expired/unset cookie
214
- return false;
215
- }
216
-
217
- this.cookies[i] = cookie;
218
- return true;
219
- }
220
- }
221
-
222
- // add as new if not already expired
223
- if (!this.isExpired(cookie)) {
224
- this.cookies.push(cookie);
225
- }
226
-
227
- return true;
228
- }
229
-
230
- /**
231
- * Checks if two cookie objects are the same
232
- *
233
- * @param {Object} a Cookie to check against
234
- * @param {Object} b Cookie to check against
235
- * @returns {Boolean} True, if the cookies are the same
236
- */
237
- compare(a, b) {
238
- return a.name === b.name && a.path === b.path && a.domain === b.domain && a.secure === b.secure && a.httponly === b.httponly;
239
- }
240
-
241
- /**
242
- * Checks if a cookie is expired
243
- *
244
- * @param {Object} cookie Cookie object to check against
245
- * @returns {Boolean} True, if the cookie is expired
246
- */
247
- isExpired(cookie) {
248
- return (cookie.expires && cookie.expires < new Date()) || !cookie.value;
249
- }
250
-
251
- /**
252
- * Returns normalized cookie path for an URL path argument
253
- *
254
- * @param {String} pathname
255
- * @returns {String} Normalized path
256
- */
257
- getPath(pathname) {
258
- let path = (pathname || '/').split('/');
259
- path.pop(); // remove filename part
260
- path = path.join('/').trim();
261
-
262
- // ensure path prefix /
263
- if (path.charAt(0) !== '/') {
264
- path = '/' + path;
265
- }
266
-
267
- // ensure path suffix /
268
- if (path.substr(-1) !== '/') {
269
- path += '/';
270
- }
271
-
272
- return path;
273
- }
274
- }
275
-
276
- module.exports = Cookies;