Cant use Crypto in SuiteCommerce Advanced Service?

389
March 01, 2017, at 12:14 PM

My SuiteScript Service MyService.Service.ss file is attempting to use the Node.js library Crypto but I get the error Error: No crypto when I run my service.

Does the Node.js version that SCA uses not have the Crypto library installed? Do I need to explicitly add Crypto as a dependency to distro.json? If so where? Do I need to install Crypto? If so, any advice how - I'm new to Node.js.

I am using pretty much standard Crypto functions, see below for the code that causes the problem:

function service (request)
{
    'use strict';
    var crypto = require('crypto'); // Error here
    var token = crypto.createHmac('md5', public_key)
               .update(private_key)
               .digest('hex');
    ...
}
Answer 1

Netsuite doesn't use the V8 engine so you are pretty much out of luck with crypto.

I've used Paul Johnston's md5 package for hmac calc for years and it is fast enough and interoperates well. Name says MD5 but it includes SHA-1,256,512 as well.

READ ALSO
Redirect URL inside Node Request

Redirect URL inside Node Request

I am trying to redirect to another url immediately after my 1st url request is completedThe reason for that is because in order to open 2nd url, it requires the 1st url session cookie

332