sidebase / nuxt-session

Nuxt session middleware to get a persistent session per app user, e.g., to store data across multiple requests. The nuxt session module provides the useSession() composable out of the box and sets up API endpoints to interact with your session to make working with sessions feel like a breeze.
https://sidebase.io/nuxt-session/
MIT License
189 stars 19 forks source link

Unexpected character '�' after upgrade #34

Open blumgart opened 1 year ago

blumgart commented 1 year ago

Environment


Reproduction

No response

Describe the bug

After upgrade from 0.2.3 to 0.2.5 and trying yarn build i get this error:

MZ�♥♦���☺▼�� �!�☺L�!This program cannot be run in DOS mode.
     ^
�n'�R�n'�Richo'�PEd��sjc�" �U��e'�=R��a'�=R�f'�=R��F'�U�l'�o'��'�R��g'�R�n'�R
☻↔�☺↑☺↑�►�☺►☻♠♠@♥♦☻`☺►►►►►p�☻�☻¶�☻( ♥�☺�☻$♥0�☻pЅ☻8☺☻�☻\�☻@.text0�☺►�☺♦ `.rdata��☻��☺@@.datap▼�☻�☻@�.pdata$☻∟�☻@@_RDATA�►♥☻�☻@@.rsrc�☺ ♥☻�☻@@.reloc00�☻3�H��(H�%��☺3�H��(�������������H�♣�}☻H�☺H�H�H�������������H�H�♣♣z☻H��HE���������������@SH��0H�♣��☻H��H��t☻��H�♥H���P►E3�H�D$ E3�3�3��������������������������@SH�� H�♣+}☻H��H�☺��☺t
-y☻耙����������������H�☺�������������@SH�� H�Q@H��H��►r-H�I(H��H��►r↑L�A�H��'I+�H�A�H��▼wMI��蠈H�C8H�♣↓|☻H�C@�C(H�♥H�S↑H��t↑�{ u

 ERROR  Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)

  at error (/E:/Projects/ns-project/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
  at Module.error (/E:/Projects/ns-project/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
  at Module.tryParse (/E:/Projects/ns-project/node_modules/rollup/dist/es/shared/rollup.js:12806:25)
  at Module.setSource (/E:/Projects/ns-project/node_modules/rollup/dist/es/shared/rollup.js:12711:24)
  at ModuleLoader.addModuleSource (/E:/Projects/ns-project/node_modules/rollup/dist/es/shared/rollup.js:21959:20)

Similar problem - nuxt/nuxt.js#15057

npm ls argon2

PS E:\Projects\ns-project> npm ls argon2
ns-project@ E:\Projects\ns-project
└─┬ @sidebase/nuxt-session@0.2.5
  └── argon2@0.30.2

Additional context

No response

Logs

No response

BracketJohn commented 1 year ago

Hey @blumgart, thanks for the issue!

pinging @Voltra who implemented this, care to have a look? -> interesting that somebody switched to bcrypt because of it here: https://github.com/nuxt/nuxt.js/issues/15057 (very good link, thanks @blumgart)

chexburger commented 1 year ago

Encountering the same issue. Resolved once the package was removed.

chexburger commented 1 year ago

@BracketJohn Just confirmed Argon2 to be the issue preventing building.

import * as bcrypt from 'bcrypt';
. . .
export const hashIpAddress = (ip) => !ip ? Promise.resolve(void 0) : bcrypt.hashSync(ip);
export const ipAddressesMatch = (ip, ipHash) => !ip && !ipHash ? Promise.resolve(false) : bcrypt.compareSync(ip, ipHash);

That snippet does not use any salt rounds and defaults to 10. Replacing those respective lines from Argon2 to bcrypt fixes the problem with no build issues. I have not tested this properly yet as I do not use this feature so I have not opened a pull request on this. https://github.com/sidebase/nuxt-session/blob/main/src/runtime/server/middleware/session/ipPinning.ts