Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "octonode in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'octonode' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

it('can create a new token', function (done) {
        // Mock the api responses
        var creds = {
                username: 'fakeuser',
                password: 'fakepass'
            },
            configSpy = sandbox.spy(octonode.auth, 'config'),
            loginStub = sandbox.stub(octonode.auth, 'login', function (scopes, cb) {
                cb(null, 1, 'Created Token');
            });

        auth.askForGithubCredentials = sandbox.stub().returns(Promise.resolve(creds));
        auth.saveToken = sandbox.stub().returns(Promise.resolve({
                saveto: 'fakepath',
                tokenId: 1,
                token: 'Created Token'
            }));

        auth.token().then(function (token) {
            configSpy.calledWithExactly(creds).should.equal(true);
            token.should.equal('Created Token');

            done();
function fetchSourceCodeFromGithubRepo () {

      // console.log('fetch source code from github')

      // in the middleware configuration, assume we already have an access token
      // access token must be done through github oauth login
      var token = config.token;

      if (typeof token === "undefined") {
        throw new Error('token is a required option!');
      }

      var client = github.client(token);

      var repo = config.repo || "Stackvana/microcule-examples";
      var branch = config.branch || "master";
      var main = config.main || "index.js";

      var ghrepo = client.repo(repo, branch);

      ghrepo.contents(main, function (err, file) {
        if (err) {
          return config.errorHandler(err, next);
        }
        req.code = base64Decode(file.content).toString();
        next();
        provider.set(key, req.code, function(err, _set){
        });
      });
var _ = require('lodash');
var Q = require('q');
var configService = require('./app/models/configurationService')();
var CONFIG = configService.get();
var dbLibrary = CONFIG.testDB ? 'monkey-js' : 'monk';
var monk = require(dbLibrary);
var async = require('async');
var utilities = require('./utilities');
var github = require('octonode');
var request = require('request');
var colors = require('colors');
var client = github.client({
  username: CONFIG.githubUser,
  password: CONFIG.githubPassword
});
var console = require('./app/models/consoleService')();

var url = CONFIG.databaseUrl;
var db = monk(url);
var apiUrl = 'https://api.github.com/repos/';

var collections = {
  repos: db.get('repos'),
  users: db.get('users'),
  // uses to store additional private user data
  userSettings: db.get('auth_users')
};
}).login(['user', 'repo', 'gist'], function(err, id, token) {
        settings.token = token; // save the client token
        settings.client = github.client(settings.token); // create a client object
        settings.client.get('/user', function(err, status, body) { // get user details
            settings.info = body;
        });

        ghgist = settings.client.gist(); // create a reference to gist api
        res.send({
            id: id,
            token: token,
            err: err
        });
    });
oauth.login = function(req, res) {
    var gotoNextStep = !!req.query.next_step;
    if (req.session.loginName) {
        // if has session.loginName, logined
        res.redirect(302, '/' + (gotoNextStep ? '#step-2' : ''));
        return;
    }
    // oauth login url
    var authUrl = github.auth.login(['read:org']);
    // Store info to verify against CSRF
    req.session.authState = authUrl.match(/&state=([0-9a-z]{32})/i)[1];
    if (gotoNextStep) {
        req.session.gotoNextStep = true;
    }

    res.redirect(302, authUrl);
};
exports.auth = function(req, res) {

    res.contentType('application/json');

    // authenticate
    github.auth.config({
        username: req.params.user,
        password: req.params.pass
    }).login(['user', 'repo', 'gist'], function(err, id, token) {
        settings.token = token; // save the client token
        settings.client = github.client(settings.token); // create a client object
        settings.client.get('/user', function(err, status, body) { // get user details
            settings.info = body;
        });

        ghgist = settings.client.gist(); // create a reference to gist api
        res.send({
            id: id,
            token: token,
            err: err
        });
    });
getGithubToken = function (credentials) {
				octonode.auth.config(credentials);

				var authRequestData = {
						scopes: ['gist', 'repo'],
						// TODO: Include current working directory name or something instead of date?
						note: 'git-at-me created on ' + (new Date().toDateString())
					},
					getAuthToken = Promise.promisify(octonode.auth.login, octonode.auth);

				return getAuthToken(authRequestData);
			};
/*jshint laxbreak:true */

/*
 * GET login / auth page.
 */

var Q = require('q');
var nconf = require('nconf');
var github = require('octonode');
var User = require('../models/User');
var winston = require('winston');

var oauth = {};

github.auth.config({
    id: nconf.get('github:clientId'),
    secret: nconf.get('github:clientSecret')
});

oauth.login = function(req, res) {
    var gotoNextStep = !!req.query.next_step;
    if (req.session.loginName) {
        // if has session.loginName, logined
        res.redirect(302, '/' + (gotoNextStep ? '#step-2' : ''));
        return;
    }
    // oauth login url
    var authUrl = github.auth.login(['read:org']);
    // Store info to verify against CSRF
    req.session.authState = authUrl.match(/&state=([0-9a-z]{32})/i)[1];
    if (gotoNextStep) {
var authCallback = function(req, res, next) {
  var cookies = new Cookies(req, res);

  github.auth.login(req.query.code, function(err, token) {
    // If we got a token, save it to a cookie
    if (token) {
      tokenHelpers.setToken(cookies, token);
    }
    // Then redirect the user
    res.writeHead(301, {'Content-Type': 'text/plain', 'Location': '/'});
    res.end();
  });
};
exports.auth = function(req, res) {

    res.contentType('application/json');

    // authenticate
    github.auth.config({
        username: req.params.user,
        password: req.params.pass
    }).login(['user', 'repo', 'gist'], function(err, id, token) {
        settings.token = token; // save the client token
        settings.client = github.client(settings.token); // create a client object
        settings.client.get('/user', function(err, status, body) { // get user details
            settings.info = body;
        });

        ghgist = settings.client.gist(); // create a reference to gist api
        res.send({
            id: id,
            token: token,
            err: err
        });
    });

Is your System Free of Underlying Vulnerabilities?
Find Out Now