RSAForPostman icon indicating copy to clipboard operation
RSAForPostman copied to clipboard

"ReferenceError: window is not defined " in Postman

Open VipinMishra opened this issue 5 years ago • 3 comments

Hi, I am follow all the steps and try to use RSA encryption in postman but getting error "ReferenceError: window is not defined". Please help me to fix this issues.

Capture

VipinMishra avatar Feb 11 '20 14:02 VipinMishra

@VipinMishra did you build yourself or just use my existing script. If you build yourself remember modify umd to var as my description. Or you can download my existing forge.js and try again

loveiset avatar Feb 12 '20 08:02 loveiset

Hello I used the file you provided, but I still encountered the same problem. this tip is also: ReferenceError: window is not defined Can you help me?

Thanks

luowuzhe23 avatar Feb 14 '20 09:02 luowuzhe23

I was having the same issue. Here's my solution:

  1. clone the forge repo https://github.com/digitalbazaar/forge.git
  2. add the package global to the cloned forge project npm i global --save-dev
  3. update the webpack.config.js, replacing 'umd' with 'var' as @loveiset has done and update the plugins to add global/window:
  const bundle = Object.assign({}, common, {
    mode: 'development',
    output: {
      path: path.join(__dirname, 'dist'),
      filename: info.filenameBase + '.js',
      library: info.library || '[name]',
      libraryTarget: info.libraryTarget || 'var'
    },
    plugins: [
      new webpack.ProvidePlugin({
        window: 'global/window',
      }),
    ]
  });
  if (info.library === null) {
    delete bundle.output.library;
  }
  if (info.libraryTarget === null) {
    delete bundle.output.libraryTarget;
  }

  // optimized and minified bundle
  const minify = Object.assign({}, common, {
    mode: 'production',
    output: {
      path: path.join(__dirname, 'dist'),
      filename: info.filenameBase + '.min.js',
      library: info.library || '[name]',
      libraryTarget: info.libraryTarget || 'var'
    },
    devtool: 'cheap-module-source-map',
    plugins: [
      new webpack.ProvidePlugin({
        window: 'global/window',
      }),
    ]
  });
  1. build the project npm run build. copy dist/forge.js to Postman

Hope that helps!

crcass avatar Oct 19 '21 16:10 crcass