Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

suiteplus/nsconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nsconfig NPM version Build Status Coveralls Status

Configuration options for netsuite-related packages.

Set up authentication and custom parameters environment-wise or project-wise.

Required

  • node.js 0.10+ or io.js 1+ or node.js 4+

Install Dependency Status devDependency Status

    npm install suiteplus/nsconfig

WARNING: The version on NPM is outdated, use the command above to install from GitHub

Usage

nsconfig( overrideParams : any , projectParams? : ParamsDef[] , noThrow? : boolean )

Reads configuration parameters from the following sources (overriding each parameter on the same order):

  • overrideParams argument;

  • Searches up to 5 levels above cwd for a nsconfig.json file

  • Searches for a ~/.ns/nsconfig.json (on windows ~ is X:/Users/<user>)

  • Environment variables found with the syntax NSCONF_<UPPERCASE_PARAMETER_NAME>. E.g. the email param can be forced to something else by exporting [email protected].

When working with multiple netsuite environments you may override the file name nsconfig.json with e.g. nsconfig-myproject.json by either:

  • setting the conffile parameter;

  • setting the environment variable NSCONF or NSCONF_CONFFILE.

projectParams

Set additional parameters that your module may want to look up.

The default parameters are:

[
    {name: 'email', required: true},
    {name: 'password', required: true},
    {name: 'account', required: true},
    {name: 'realm', def: 'system.netsuite.com'},
    {name: 'role'},
    {name: 'consumerKey'},
    {name: 'consumerSecret'},
    {name: 'token'},
    {name: 'tokenSecret'}
]

Currently accepted options for each custom parameter are:

interface ParamsDef {
	name : string;
	required? : boolean; //throws an error if this parameter is not defined
	def? : boolean;      //defaults to this value if this parameter is not defined
}

passwords and passwordHash

Instead of setting the password key, you may set passwordHash with a base64 encoded password.

Or you may use one the following options in order to avoid storing the password directly into the project's nsconfig.json:

  • Set up the password as environment variable (NSCONF_PASSWORD)

  • Set the the password at ~/.ns/nsconfig.json

Token Based Authentication

When using token based authentication, the following 4 values are required:

  • consumerKey
  • consumerSecret
  • token
  • tokenSecret

Setup:

  • Enable Token-based Authentication (Enable Features > SuiteCloud > Manage Authentication)
  • Create an integration record to generate a consumer key and secret
  • Generate a user token (must enable a role with User Access Tokens permission - Administrator role cannot be used)

The email and password are ignored when token based authentication is used. (They are still required but can just have placeholder values)

Example

Both configuration files below yield the same output:

var params = nsconfig()

yields

{
	"email": "[email protected]",
	"password": "*****",
	"account": "DDAA12321",
	"realm": "netsuite.com",
	"role": 3
}