### Install asynckit Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/asynckit/README.md Install the asynckit module using npm. ```sh $ npm install --save asynckit ``` -------------------------------- ### Install json-schema-traverse Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/json-schema-traverse/README.md Install the library using npm. ```bash npm install json-schema-traverse ``` -------------------------------- ### Basic Usage of performance-now Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/performance-now/README.md Demonstrates how to require the module, get start and end timestamps, and log the elapsed time in milliseconds with three decimal places. Note that consecutive calls have a small overhead. ```javascript var now = require("performance-now") var start = now() var end = now() console.log(start.toFixed(3)) // the number of milliseconds the current node process is running console.log((start-end).toFixed(3)) // ~ 0.002 on my system ``` -------------------------------- ### Install co Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/co/Readme.md Install the co library using npm. ```bash $ npm install co ``` -------------------------------- ### Install getpass Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/getpass/README.md Install the getpass module using npm. ```bash npm install --save getpass ``` -------------------------------- ### Starting and Stopping Background Offset Refresh Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/sntp/README.md Illustrates how to start a background offset refresh interval and use the `now()` method to get the system time with the applied offset. It also shows how to stop the refresh. ```javascript var before = Sntp.now(); // System time without offset Sntp.start(function () { var now = Sntp.now(); // With offset Sntp.stop(); }); ``` -------------------------------- ### No Proxy Configuration Examples Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Examples of valid values for the NO_PROXY environment variable to opt out of proxying for specific hosts or ports. ```text google.com ``` ```text google.com:443 ``` ```text google.com:443, yahoo.com:80 ``` ```text * ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/ajv/README.md Installs project dependencies, updates git submodules, and runs the test suite. ```bash npm install git submodule update --init npm test ``` -------------------------------- ### Install Punycode.js via Component Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/punycode/README.md Install the library using the Component package manager. ```bash component install bestiejs/punycode.js ``` -------------------------------- ### Install sshpk Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/sshpk/README.md Install the sshpk package using npm. ```bash npm install sshpk ``` -------------------------------- ### Install safe-buffer Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/safe-buffer/README.md Install the safe-buffer package using npm. ```bash npm install safe-buffer ``` -------------------------------- ### HTTP Request Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/http-signature/http_signing.md This is a sample HTTP POST request used in the examples. ```http POST /foo?param=value&pet=dog HTTP/1.1 Host: example.com Date: Thu, 05 Jan 2014 21:31:40 GMT Content-Type: application/json Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE= Content-Length: 18 {"hello": "world"} ``` -------------------------------- ### Example Output: String Option Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Illustrates parsing a string option with its value, showing how the option and its argument are captured. ```bash $ node foo.js -f bar.txt # opts: { file: 'bar.txt', _order: [ { name: 'file', value: 'bar.txt', from: 'argv' } ], _args: [] } # args: [] ``` -------------------------------- ### Install mime-db Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/mime-db/README.md Install the mime-db package using npm. ```bash npm install mime-db ``` -------------------------------- ### Example help output with group headings Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Shows the resulting help output when using group headings to structure options. ```text ... Armament Options: -w, --weapon General Options: -h, --help ... ``` -------------------------------- ### Example Output: Version Option with Argument Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Demonstrates parsing the version option along with an additional argument, showing how arguments not matching options are collected in `_args`. ```bash $ node foo.js --version arg1 # opts: { version: true, _order: [ { name: 'version', value: true, from: 'argv' } ], _args: [ 'arg1' ] } # args: [ 'arg1' ] ``` -------------------------------- ### Example Output: Help Message Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Illustrates the output when the help option is invoked, showing the generated usage and options based on the parser configuration. ```bash $ node foo.js -h # opts: { help: true, _order: [ { name: 'help', value: true, from: 'argv' } ], _args: [] } # args: [] usage: node foo.js [OPTIONS] options: --version Print tool version and exit. -h, --help Print this help and exit. -v, --verbose Verbose output. Use multiple times for more verbose. -f FILE, --file=FILE File to process ``` -------------------------------- ### Install combined-stream Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/combined-stream/Readme.md Install the combined-stream module using npm. ```bash npm install combined-stream ``` -------------------------------- ### Install NPM Modules for Development Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/tweetnacl/README.md Installs the necessary Node.js packages for developing and testing TweetNaCl.js. ```bash $ npm install ``` -------------------------------- ### Initialize Caseless Wrapper Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/caseless/README.md Instantiate the caseless wrapper with an object. This is the initial setup for using caseless semantics. ```javascript var headers = {} , c = caseless(headers) ; ``` -------------------------------- ### Install extend Package Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/extend/README.md Install the extend package using npm. ```sh npm install extend ``` -------------------------------- ### Install extsprintf Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/extsprintf/README.md Install the extsprintf module using npm. This is a prerequisite for using the module in your Node.js project. ```bash # npm install extsprintf ``` -------------------------------- ### Install Punycode.js via Bower Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/punycode/README.md Install the library using Bower for front-end package management. ```bash bower install punycode ``` -------------------------------- ### Install delayed-stream Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/delayed-stream/Readme.md Install the delayed-stream module using npm. ```bash npm install delayed-stream ``` -------------------------------- ### Install AJV using npm Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/ajv/README.md Install the AJV package using npm. This is the first step to using AJV in your Node.js project. ```bash npm install ajv ``` -------------------------------- ### Bash Completion Example (Before) Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Illustrates the output of dashdash's Bash completion support before a fix for sorting rules. ```bash $ triton -v -p test2 package get # before ##-no -tritonpackage- completions-## ``` -------------------------------- ### Run Performance Benchmark Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/fast-deep-equal/README.md Instructions to run the performance benchmark for fast-deep-equal. This requires installing dependencies and executing the benchmark script. ```bash npm install node benchmark ``` -------------------------------- ### OAuth 1.0 Signing (Twitter Example) Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Provides a multi-step example of implementing OAuth 1.0 signing for API requests, specifically using the Twitter API. This covers the server-side flow for obtaining request tokens, user authentication, and access tokens. ```javascript // OAuth1.0 - 3-legged server side flow (Twitter example) // step 1 var qs = require('querystring') , oauth = { callback: 'http://mysite.com/callback/' , consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET } , url = 'https://api.twitter.com/oauth/request_token' ; request.post({url:url, oauth:oauth}, function (e, r, body) { // Ideally, you would take the body in the response // and construct a URL that a user clicks on (like a sign in button). // The verifier is only available in the response after a user has // verified with twitter that they are authorizing your app. // step 2 var req_data = qs.parse(body) var uri = 'https://api.twitter.com/oauth/authenticate' + '?' + qs.stringify({oauth_token: req_data.oauth_token}) // redirect the user to the authorize uri // step 3 // after the user is redirected back to your server var auth_data = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: auth_data.oauth_token , token_secret: req_data.oauth_token_secret , verifier: auth_data.oauth_verifier } , url = 'https://api.twitter.com/oauth/access_token' ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user var perm_data = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret } , url = 'https://api.twitter.com/1.1/users/show.json' , qs = { screen_name: perm_data.screen_name , user_id: perm_data.user_id } ; request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { console.log(user) }) }) }) ``` -------------------------------- ### Install Punycode.js via npm Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/punycode/README.md Use this command to install the library if you are using a Node.js version older than v0.6.2. ```bash npm install punycode ``` -------------------------------- ### Bash Completion Example (After) Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Illustrates the output of dashdash's Bash completion support after a fix for sorting rules. ```bash $ triton -v -p test2 package get # after ##-no-completion- -results-## ``` -------------------------------- ### Bash Completion with Argtypes Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Demonstrates Bash completion with custom argtypes for positional arguments, requiring specExtra functions. ```bash # E.g. this would allow you to have an `ssh` command with `argtypes = ['host', # 'cmd']` for bash completion. You then have to provide Bash functions to # handle completing those types via the `specExtra` arg. See # "[examples/ddcompletion.js](examples/ddcompletion.js)" for an example. ``` -------------------------------- ### SynopsisFromOpt Example: String Option Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Generates a synopsis string for a string option with a help argument using synopsisFromOpt. ```javascript > synopsisFromOpt({name: 'file', type: 'string', helpArg: 'FILE'}); '[ --file=FILE ]' ``` -------------------------------- ### Install mime-types Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/mime-types/README.md Install the mime-types module using npm. This is a standard Node.js module. ```sh npm install mime-types ``` -------------------------------- ### Generate Signature with openssl Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/http-signature/http_signing.md Example of generating an RSA-SHA256 signature using `openssl` command line. ```bash $ printf 'date: Thu, 05 Jan 2014 21:31:40 GMT' | \ openssl dgst -binary -sign /path/to/private.pem -sha256 | \ openssl enc -base64 jKyvPcxB4JbmYY4mByyBY7cZfNl4OW9Hp... ``` -------------------------------- ### Install uuid Module Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/uuid/README.md Install the uuid module using npm. This is the recommended first step for using the library in a Node.js project. ```shell npm install uuid ``` -------------------------------- ### Install form-data Package Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/form-data/README.md Install the form-data package using npm. This is a prerequisite for using the library in your Node.js project. ```bash npm install --save form-data ``` -------------------------------- ### Install fast-deep-equal Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/fast-deep-equal/README.md Install the fast-deep-equal package using npm. This command is used to add the library to your project's dependencies. ```bash npm install fast-deep-equal ``` -------------------------------- ### Verify Signature with openssl Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/http-signature/http_signing.md Example of verifying an RSA-SHA256 signature using `openssl` command line. ```bash $ echo 'jKyvPcxB4JbmYY...' | openssl enc -A -d -base64 > signature $ printf 'date: Thu, 05 Jan 2014 21:31:40 GMT' | \ openssl dgst -sha256 -verify /path/to/public.pem -signature ./signature Verified OK ``` -------------------------------- ### Usage Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/mime-db/README.md Require the mime-db module and access data for a specific MIME type, such as 'application/javascript'. ```javascript var db = require('mime-db'); // grab data on .js files var data = db['application/javascript']; ``` -------------------------------- ### Create HTTP Server with Streaming Proxy Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Example of creating an HTTP server that pipes incoming requests to an external service and streams the response back. ```javascript http.createServer(function (req, resp) { if (req.url === '/doodle.png') { if (req.method === 'PUT') { req.pipe(request.put('http://mysite.com/doodle.png')) } else if (req.method === 'GET' || req.method === 'HEAD') { request.get('http://mysite.com/doodle.png').pipe(resp) } } }) ``` -------------------------------- ### Run Headless Browser Tests Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/tweetnacl/README.md Executes tests in a headless browser environment using tape-run. Requires xvfb to be installed. ```bash $ npm run test-browser ``` -------------------------------- ### Example Output: Verbose Option Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Shows the parsed options when the verbose flag is used, demonstrating how `arrayOfBool` type handles repeated flags. ```bash $ node foo.js -v # opts: { verbose: [ true ], _order: [ { name: 'verbose', value: true, from: 'argv' } ], _args: [] } # args: [] ``` -------------------------------- ### startsWith(str, prefix) Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/jsprim/README.md Returns true if the given string starts with the given prefix and false otherwise. ```APIDOC ## startsWith(str, prefix) ### Description Returns true if the given string starts with the given prefix and false otherwise. ### Parameters * **str** (string) - The string to check. * **prefix** (string) - The prefix to look for. ### Returns (boolean) - True if the string starts with the prefix, false otherwise. ``` -------------------------------- ### Start Background Offset Refresh Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/sntp/README.md Starts a background process to refresh the clock offset periodically. The `now()` method can then be used to get the synchronized time. ```APIDOC ## Sntp.start(callback) ### Description Starts a background interval to refresh the clock offset. Use `Sntp.now()` to get the synchronized time. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Callback Function - **callback** (function) - A function to be called when the interval starts. ### Request Example ```javascript var Sntp = require('sntp'); Sntp.start(function () { var now = Sntp.now(); // With offset Sntp.stop(); }); ``` ### Response None directly from `start`, but subsequent calls to `Sntp.now()` will reflect the synchronized time. ``` -------------------------------- ### Basic HTTP Request Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Demonstrates how to make a simple GET request to a URL and handle the response. Requires the 'request' module to be imported. ```javascript var request = require('request'); request('http://www.google.com', function (error, response, body) { console.log('error:', error); // Print the error if one occurred console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received console.log('body:', body); // Print the HTML for the Google homepage. }); ``` -------------------------------- ### Set and Get Header Caselessly Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/caseless/README.md Demonstrates setting a header with specific casing and retrieving it using a different casing. The library preserves the initial casing. ```javascript c.set('a-Header', 'asdf') c.get('a-header') === 'asdf' ``` -------------------------------- ### Set Request Timeout Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Set a timeout for a GET request to prevent indefinite hanging. This example demonstrates how to set a timeout and check for timeout errors, distinguishing between connection and read timeouts. ```javascript request.get('http://10.255.255.1', {timeout: 1500}, function(err) { console.log(err.code === 'ETIMEDOUT'); // Set to `true` if the timeout was a connection timeout, `false` or // `undefined` otherwise. console.log(err.connect === true); process.exit(0); }); ``` -------------------------------- ### Install HAR Schema Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/har-schema/README.md Install the har-schema package using npm. This command installs only production dependencies. ```bash npm install --only=production --save har-schema ``` -------------------------------- ### Install HAR Validator Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/har-validator/README.md Install the HAR Validator module using npm. This command installs the module for production use and saves it as a dependency. ```bash npm install --only=production --save har-validator ``` -------------------------------- ### Sign and Send CloudFront Request for Distributions Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/aws4/README.md Sign a CloudFront request to list distributions. This example demonstrates signing requests for the CloudFront service. ```javascript request(aws4.sign({service: 'cloudfront', path: '/2014-05-31/distribution'})) ``` -------------------------------- ### Prepare Browser Tests Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/tweetnacl/README.md Builds the necessary files to run tests in a web browser. Open test/browser/test.html or test/browser/test-fast.html to run. ```bash $ npm run build-test-browser ``` -------------------------------- ### Example Output: Multiple Verbose and String Options Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Shows parsing multiple instances of a verbose flag and a string option with its value, demonstrating how repeated options and combined arguments are handled. ```bash $ node foo.js -vvv --file=blah # opts: { verbose: [ true, true, true ], file: 'blah', _order: [ { name: 'verbose', value: true, from: 'argv' }, { name: 'verbose', value: true, from: 'argv' }, { name: 'verbose', value: true, from: 'argv' }, { name: 'file', value: 'blah', from: 'argv' } ], _args: [] } # args: [] ``` -------------------------------- ### Environment Variable Fallback Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Shows how to configure an option to fall back to an environment variable if not provided on the command line. This is useful for setting default configurations that can be overridden. ```javascript var options = [{names: ['dry-run', 'n'], env: 'FOO_DRY_RUN'}]; var opts = dashdash.parse({options: options}); ``` -------------------------------- ### Proxy Configuration with Defaults Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Create a Request instance with default proxy settings, then use it to make proxied requests within an HTTP server. ```javascript var r = request.defaults({'proxy':'http://localproxy.com'}) http.createServer(function (req, resp) { if (req.url === '/doodle.png') { r.get('http://google.com/doodle.png').pipe(resp) } }) ``` -------------------------------- ### Advanced Usage with Parser Creation Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Shows a more realistic example using `dashdash.createParser` and `parser.help()` for formatted option help. This allows for more control and features like including environment variables in help messages. ```javascript var dashdash = require('./lib/dashdash'); var options = [ { name: 'version', type: 'bool', help: 'Print tool version and exit.' }, { names: ['help', 'h'], type: 'bool', help: 'Print this help and exit.' }, { names: ['verbose', 'v'], type: 'arrayOfBool', help: 'Verbose output. Use multiple times for more verbose.' }, { names: ['file', 'f'], type: 'string', help: 'File to process', helpArg: 'FILE' } ]; var parser = dashdash.createParser({options: options}); try { var opts = parser.parse(process.argv); } catch (e) { console.error('foo: error: %s', e.message); process.exit(1); } console.log("# opts:", opts); console.log("# args:", opts._args); // Use `parser.help()` for formatted options help. if (opts.help) { var help = parser.help({includeEnv: true}).trimRight(); console.log('usage: node foo.js [OPTIONS]\n' + 'options:\n' + help); process.exit(0); } // ... ``` -------------------------------- ### Install aws4 Module Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/aws4/README.md Install the aws4 module using npm for use in your Node.js project. ```bash npm install aws4 ``` -------------------------------- ### Setting a Specific Cookie and Using Custom Jar Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md This example shows how to create a cookie, set it in a custom jar, and then use that jar for requests. The cookie will be sent to the specified URL. ```javascript var j = request.jar(); var cookie = request.cookie('key1=value1'); var url = 'http://www.google.com'; j.setCookie(cookie, url); request({url: url, jar: j}, function () { request('http://images.google.com') }) ``` -------------------------------- ### Option with Environment Variable but no Help Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Demonstrates how an option with an environment variable but no explicit help text is handled. The environment variable is still used for output. ```javascript { names: ['foo'], type: 'string', env: 'FOO' } ``` -------------------------------- ### Checking if a String Starts with a Prefix Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/jsprim/README.md Returns true if the given string starts with the given prefix and false otherwise. ```javascript startsWith(str, prefix) ``` -------------------------------- ### Example usage of date and arrayOfDate option types Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Shows how to use the 'date' and 'arrayOfDate' option types with epoch second or ISO 8601 formatted arguments, and displays the parsed output. ```bash $ node examples/date.js -s 2014-01-01 -e $(date +%s) start at 2014-01-01T00:00:00.000Z end at 2014-03-29T04:26:18.000Z ``` -------------------------------- ### Set Option via Environment Variable (String) Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Demonstrates setting a string option 'file' using the 'FOO_FILE' environment variable. ```shell $ FOO_FILE=data.txt node examples/foo.js # opts: { file: 'data.txt', _order: [ { key: 'file', value: 'data.txt', from: 'env' } ], _args: [] } # args: [] ``` -------------------------------- ### Sign and Send STS Request to Get Session Token Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/aws4/README.md Sign an STS request to get a session token. This is a common operation for temporary credentials. ```javascript request(aws4.sign({service: 'sts', path: '/?Action=GetSessionToken&Version=2011-06-15'})) ``` -------------------------------- ### Vulnerable HTTP Server Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/safe-buffer/README.md This Node.js HTTP server example is vulnerable to remote memory disclosure. It parses a JSON payload and converts the 'str' property to hex using the unsafe Buffer constructor. ```javascript // Take a JSON payload {str: "some string"} and convert it to hex var server = http.createServer(function (req, res) { var data = '' req.setEncoding('utf8') req.on('data', function (chunk) { data += chunk }) req.on('end', function () { var body = JSON.parse(data) res.end(new Buffer(body.str).toString('hex')) }) }) server.listen(8080) ``` -------------------------------- ### Example: 'yesno' Custom Option Type Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md This example shows how to create a custom 'yesno' option type that parses 'yes', 'y', 'no', or 'n' into boolean values. It includes a custom parsing function and demonstrates how to use this new type in the options configuration. ```javascript var dashdash = require('dashdash'); function parseYesNo(option, optstr, arg) { var argLower = arg.toLowerCase() if (~['yes', 'y'].indexOf(argLower)) { return true; } else if (~['no', 'n'].indexOf(argLower)) { return false; } else { throw new Error(format( 'arg for "%s" is not "yes" or "no": "%s"', optstr, arg)); } } dashdash.addOptionType({ name: 'yesno' takesArg: true, helpArg: '', parseArg: parseYesNo }); var options = { {names: ['answer', 'a'], type: 'yesno'} }; var opts = dashdash.parse({options: options}); ``` -------------------------------- ### Short Option Group Parsing Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Illustrates a scenario where a short option group is parsed, including an option that takes an argument. This example shows the correct parsing of `tail -fn5`, where `-f` is a boolean option and `-n` takes a numeric argument. ```bash tail -fn5 ``` -------------------------------- ### Get Punycode.js Version Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/punycode/README.md Access the current version number of the Punycode.js library. ```javascript punycode.version; ``` -------------------------------- ### Verify Signature with sshpk-verify Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/http-signature/http_signing.md Example of verifying an RSA-SHA256 signature using the `sshpk-verify` tool. ```bash $ printf 'date: Thu, 05 Jan 2014 21:31:40 GMT' | \ sshpk-verify -i ./public.pem -s 'jKyvPcxB4JbmYY...' OK ``` -------------------------------- ### Generate Signature with sshpk-sign Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/http-signature/http_signing.md Example of generating an RSA-SHA256 signature using the `sshpk-sign` tool. ```bash $ printf 'date: Thu, 05 Jan 2014 21:31:40 GMT' | \ sshpk-sign -i /path/to/private.pem jKyvPcxB4JbmYY4mByyBY7cZfNl4OW9Hp... ``` -------------------------------- ### Stream Response to File Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/request/README.md Pipe the response of a GET request directly to a file stream. ```javascript request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')) ``` -------------------------------- ### Environment Variable Integration Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Illustrates the integration of environment variables with command-line options. If an option is not provided in argv, it falls back to using the associated environment variable. ```javascript See the "Environment variable integration" section in the README. ``` -------------------------------- ### SynopsisFromOpt Example: Boolean Option Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/CHANGES.md Generates a synopsis string for a boolean option using synopsisFromOpt. ```javascript > synopsisFromOpt({names: ['help', 'h'], type: 'bool'}); '[ --help | -h ]' ``` -------------------------------- ### Basic Usage of qs.parse and qs.stringify Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/qs/README.md Demonstrates the fundamental usage of qs.parse to convert a querystring into an object and qs.stringify to convert an object back into a querystring. ```javascript var qs = require('qs'); var assert = require('assert'); var obj = qs.parse('a=c'); assert.deepEqual(obj, { a: 'c' }); var str = qs.stringify(obj); assert.equal(str, 'a=c'); ``` -------------------------------- ### combinedStream.resume Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/combined-stream/Readme.md Resumes the combined stream, causing it to start draining the managed streams and emitting a 'resume' event. ```APIDOC ## combinedStream.resume() ### Description Causes `combinedStream` to start drain the streams it manages. The function is idempotent, and also emits a `'resume'` event each time which usually goes to the stream that is currently being drained. ### Method `combinedStream.resume()` ``` -------------------------------- ### Get default extension for a content-type Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/mime-types/README.md Use `mime.extension()` to retrieve the default file extension for a given content-type. ```javascript mime.extension('application/octet-stream') // 'bin' ``` -------------------------------- ### Basic Usage of dashdash.parse Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/dashdash/README.md Demonstrates the basic usage of `dashdash.parse` to parse command-line arguments. This shortcut form infers `process.argv`. ```javascript var dashdash = require('dashdash'); // Specify the options. Minimally `name` (or `names`) and `type` // must be given for each. var options = [ { // `names` or a single `name`. First element is the `opts.KEY`. names: ['help', 'h'], // See "Option specs" below for types. type: 'bool', help: 'Print this help and exit.' } ]; // Shortcut form. As called it infers `process.argv`. See below for // the longer form to use methods like `.help()` on the Parser object. var opts = dashdash.parse({options: options}); console.log("opts:", opts); console.log("args:", opts._args); ``` -------------------------------- ### Sign and Send Autoscaling Request to Describe Instances Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/aws4/README.md Sign an Autoscaling request to describe auto scaling instances. This example shows how to sign requests for the Auto Scaling service. ```javascript request(aws4.sign({service: 'autoscaling', path: '/?Action=DescribeAutoScalingInstances&Version=2011-01-01'})) ``` -------------------------------- ### Example Schema using $merge Keyword Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/ajv/README.md Demonstrates how to use the $merge keyword to extend a JSON schema. The 'source' defines the base schema, and 'with' provides properties to merge. ```json { "$merge": { "source": { "type": "object", "properties": { "p": { "type": "string" } }, "additionalProperties": false }, "with": { "properties": { "q": { "type": "number" } } } } } ``` -------------------------------- ### Hawk Authorization Header Example Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/hawk/README.md Demonstrates the final HTTP Authorization header with Hawk authentication details, including id, timestamp, nonce, extension data, and MAC. ```http GET /resource/1?b=1&a=2 HTTP/1.1 Host: example.com:8000 Authorization: Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", ext="some-app-ext-data", mac="6R4rV5iE+NPoym+WwjeHzjAGXUtLNIxmo1vpMofpLAE=" ``` -------------------------------- ### Ignoring Query String Prefix Source: https://github.com/hyperverge/kyc-india-rest-api/blob/master/samples/node.js/node_modules/qs/README.md Explains how to use the 'ignoreQueryPrefix' option to parse querystrings that start with a question mark. ```javascript var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true }); assert.deepEqual(prefixed, { a: 'b', c: 'd' }); ```