libbase64 1.2.1 → 1.3.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.
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [andris9] # enable once enrolled
4
+ custom: ['https://www.paypal.me/nodemailer']
@@ -0,0 +1,39 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ # Manual run: publish the version currently on master (used when a release was cut
6
+ # but the publish step failed)
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ pull-requests: write
12
+ id-token: write
13
+
14
+ name: release
15
+ jobs:
16
+ release-please:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: google-github-actions/release-please-action@v3
20
+ id: release
21
+ if: ${{ github.event_name == 'push' }}
22
+ with:
23
+ release-type: node
24
+ package-name: ${{vars.NPM_MODULE_NAME}}
25
+ pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
26
+ # The logic below handles the npm publication through npm trusted publishing
27
+ # (OIDC, no token secret): it runs when a new release is created, or on a
28
+ # manual dispatch.
29
+ - uses: actions/checkout@v4
30
+ if: ${{ steps.release.outputs.release_created || github.event_name == 'workflow_dispatch' }}
31
+ - uses: actions/setup-node@v4
32
+ with:
33
+ node-version: 24
34
+ registry-url: 'https://registry.npmjs.org'
35
+ if: ${{ steps.release.outputs.release_created || github.event_name == 'workflow_dispatch' }}
36
+ - run: npm ci
37
+ if: ${{ steps.release.outputs.release_created || github.event_name == 'workflow_dispatch' }}
38
+ - run: npm publish --provenance --access public
39
+ if: ${{ steps.release.outputs.release_created || github.event_name == 'workflow_dispatch' }}
@@ -0,0 +1,21 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ matrix:
11
+ node: [16.x, 18.x, 20.x, 21.x]
12
+ os: [ubuntu-latest]
13
+ runs-on: ${{ matrix.os }}
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Use Node.js ${{ matrix.node }}
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: ${{ matrix.node }}
20
+ - run: npm install
21
+ - run: npm test
package/.ncurc.js ADDED
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ upgrade: true,
3
+ reject: [
4
+ // 12 is esm only ("type": "module"), and grunt-mocha-test require()s it as a
5
+ // constructor - "Mocha is not a constructor". Node 24 hides this through
6
+ // require(esm); CI on Node 22 does not. Lift it when the runner drops grunt.
7
+ 'mocha',
8
+ // 5x is esm only
9
+ 'chai',
10
+ // api changes in newer eslint
11
+ 'grunt-eslint'
12
+ ]
13
+ };
package/.prettierrc.js CHANGED
@@ -1,5 +1,8 @@
1
1
  module.exports = {
2
2
  printWidth: 160,
3
3
  tabWidth: 4,
4
- singleQuote: true
4
+ singleQuote: true,
5
+ endOfLine: 'lf',
6
+ trailingComma: 'none',
7
+ arrowParens: 'avoid'
5
8
  };
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## [1.3.1](https://github.com/nodemailer/libbase64/compare/v1.3.0...v1.3.1) (2026-09-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **decoder:** decode every padded segment instead of stopping at the first padding ([d9ba154](https://github.com/nodemailer/libbase64/commit/d9ba154ba13e45338936a55acec417dfb6ae2e52))
9
+
10
+ ## [1.3.0](https://github.com/nodemailer/libbase64/compare/v1.2.1...v1.3.0) (2024-02-23)
11
+
12
+
13
+ ### Features
14
+
15
+ * **deploy:** Added autodeploy system ([f53cb2e](https://github.com/nodemailer/libbase64/commit/f53cb2e8ea3c4900288a96284914da2c35bffe9f))
package/lib/libbase64.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const stream = require('stream');
3
+ const { Buffer } = require('node:buffer');
4
+ const stream = require('node:stream');
4
5
  const Transform = stream.Transform;
5
6
 
6
7
  /**
@@ -25,6 +26,22 @@ function encode(buffer) {
25
26
  */
26
27
  function decode(str) {
27
28
  str = str || '';
29
+
30
+ // Buffer.from() stops decoding at the first padding char, so input made of several
31
+ // padded segments (eg. every line padded on its own) is decoded segment by segment
32
+ if (typeof str === 'string') {
33
+ let padPos = str.indexOf('=');
34
+ if (padPos >= 0 && /[a-zA-Z0-9+/\-_]/.test(str.substr(padPos))) {
35
+ let parts = [];
36
+ for (let segment of str.split(/[=]+/)) {
37
+ if (segment) {
38
+ parts.push(Buffer.from(segment, 'base64'));
39
+ }
40
+ }
41
+ return Buffer.concat(parts);
42
+ }
43
+ }
44
+
28
45
  return Buffer.from(str, 'base64');
29
46
  }
30
47
 
@@ -214,6 +231,15 @@ class Decoder extends Transform {
214
231
  b64 = b64.replace(/[^a-zA-Z0-9+/=]/g, '');
215
232
  }
216
233
 
234
+ // everything up to the last padding char ends in complete segments, quartets are
235
+ // only counted from there on as a padding run restarts the quartet alignment
236
+ let padded = '';
237
+ let lastPad = b64.lastIndexOf('=');
238
+ if (lastPad >= 0) {
239
+ padded = b64.substr(0, lastPad + 1);
240
+ b64 = b64.substr(lastPad + 1);
241
+ }
242
+
217
243
  if (b64.length < 4) {
218
244
  this._curLine = b64;
219
245
  b64 = '';
@@ -222,6 +248,8 @@ class Decoder extends Transform {
222
248
  b64 = b64.substr(0, b64.length - this._curLine.length);
223
249
  }
224
250
 
251
+ b64 = padded + b64;
252
+
225
253
  if (b64) {
226
254
  let buf = decode(b64);
227
255
  this.outputBytes += buf.length;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "libbase64",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Encode and decode base64 encoded strings",
5
5
  "main": "lib/libbase64.js",
6
6
  "scripts": {
7
- "test": "grunt"
7
+ "test": "grunt",
8
+ "update": "rm -rf node_modules package-lock.json && ncu -u && npm install"
8
9
  },
9
10
  "repository": {
10
11
  "type": "git",
@@ -21,14 +22,14 @@
21
22
  },
22
23
  "homepage": "https://github.com/nodemailer/libbase64",
23
24
  "devDependencies": {
24
- "chai": "4.2.0",
25
+ "chai": "4.4.1",
25
26
  "eslint-config-nodemailer": "1.2.0",
26
- "eslint-config-prettier": "6.0.0",
27
- "grunt": "1.0.4",
28
- "grunt-cli": "1.3.2",
29
- "grunt-eslint": "22.0.0",
27
+ "eslint-config-prettier": "10.1.8",
28
+ "grunt": "1.6.3",
29
+ "grunt-cli": "1.5.0",
30
+ "grunt-eslint": "24.3.0",
30
31
  "grunt-mocha-test": "0.13.3",
31
- "mocha": "6.2.0"
32
+ "mocha": "10.3.0"
32
33
  },
33
34
  "dependencies": {}
34
35
  }