cleanup, stow nix, install.sh script

auto-flake-update
Yorick van Pelt 2016-01-31 21:39:49 +01:00
parent b40f9c8c45
commit f1101ae6e5
9 changed files with 0 additions and 641 deletions

View File

@ -1,8 +0,0 @@
{
"symlinks": [
{
"source": "config.nix",
"target": "~/.nixpkgs/config.nix"
},
]
}

View File

View File

@ -1,19 +0,0 @@
Copyright (c) 2011 Lajos Koszti http://ajnasz.hu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

144
node_modules/googleclientlogin/README generated vendored
View File

@ -1,144 +0,0 @@
Google's ClientLogin authentication implementation for Node.js
Requires at least nodejs 0.4.1
Properties:
errors: That is an object, filled with the possible error messages.
accountTypes: An object, where you can set the type of account to request authorization for.
properties are: google, hosted, hostedOrGoogle
default is hostedOrGoogle
Events:
login: emitted when login was success
error: emitted when an error occured. Has two parameters, the response object and the received data
You can access to their names via constants: GoogleClientLogin.events.login or GoogleClientLogin.events.error
or you can use 'login' and 'error' as string.
Methods:
login
Starts the login process. It has one optional parameter, which should be an object with two properties:
logincaptcha, logintoken.
The logincaptcha is the user's answer to the captcha question
You will receive the logintoken if the login failed and the CaptchaRequired error code arrived
You must pass both the logincaptcha and logintoken if you must pass a captcha challange
getAuthId
Returns the value of the authId key from the response. If the login was success you will need to use this value to perform additional requests. You must put it into a the Authorization header like this:
'Authorization': 'GoogleLogin auth=' + googleAuth.getAuthId(),
getSID
Returns the value of SID key from the response.
getLSID
Returns the value of LSID key from the response.
isCaptchaRequired
If the login was not success and the user need to pass a captcha challenge this method will return true
getCaptchaUrl
Url of the captcha image
getCaptchaToken
You will need to pass it back to the google with the user's answer to the captcha if the login failed and captcha authentication required.
getError
If the login was not success, google will send back an error code what you can get with this method
After the login was success, you should use the AuthId in each of your requests, see example below
http://code.google.com/apis/gdata/faq.html#clientlogin
list of services:
Name |name in googleclientlogin module |value
-----------------------------------------------------|-------------------------------------|---------------
Google Adwords APIs: |adwords: |'adwords'
-----------------------------------------------------|-------------------------------------|---------------
Google Analytics Data APIs: |analytics: |'analytics'
-----------------------------------------------------|-------------------------------------|---------------
Google Apps APIs (Domain Information & Management): |apps: |'apps'
-----------------------------------------------------|-------------------------------------|---------------
Google Base Data API: |base: |'gbase'
-----------------------------------------------------|-------------------------------------|---------------
Google Sites Data API: |sites: |'jotspot'
-----------------------------------------------------|-------------------------------------|---------------
Blogger Data API: |blogger: |'blogger'
-----------------------------------------------------|-------------------------------------|---------------
Book Search Data API: |book: |'print'
-----------------------------------------------------|-------------------------------------|---------------
Calendar Data API: |calendar: |'cl'
-----------------------------------------------------|-------------------------------------|---------------
Google Code Search Data API: |codesearch: |'codesearch'
-----------------------------------------------------|-------------------------------------|---------------
Contacts Data API: |contacts: |'cp'
-----------------------------------------------------|-------------------------------------|---------------
Documents List Data API: |docs: |'writely'
-----------------------------------------------------|-------------------------------------|---------------
Finance Data API: |finance: |'finance'
-----------------------------------------------------|-------------------------------------|---------------
Gmail Atom feed: |mail: |'mail'
-----------------------------------------------------|-------------------------------------|---------------
Health Data API: |health: |'health'
-----------------------------------------------------|-------------------------------------|---------------
Health Data API H9 Sandbox |weaver: |'weaver'
-----------------------------------------------------|-------------------------------------|---------------
Maps Data APIs: |maps: |'local'
-----------------------------------------------------|-------------------------------------|---------------
Picasa Web Albums Data API: |picasaweb: |'lh2'
-----------------------------------------------------|-------------------------------------|---------------
Sidewiki Data API: |sidewiki: |'annotateweb'
-----------------------------------------------------|-------------------------------------|---------------
Spreadsheets Data API: |spreadsheets: |'wise'
-----------------------------------------------------|-------------------------------------|---------------
Webmaster Tools API: |webmastertools: |'sitemaps'
-----------------------------------------------------|-------------------------------------|---------------
YouTube Data API: |youtube: |'youtube'
-----------------------------------------------------|-------------------------------------|---------------
C2DM Push Notification Service: |c2dm: |'ac2dm'
-----------------------------------------------------|-------------------------------------|---------------
Google Reader Data API (unofficial): |reader: |'reader'
-----------------------------------------------------|-------------------------------------|---------------
Google Voice API (unoffical): |voice: |'grandcentral'
How to use:
var GoogleClientLogin = import('googleclientlogin').GoogleClientLogin;
var googleAuth = new GoogleClientLogin({
email: 'yourmail@gmail.com',
password: 'yourpassword',
service: 'contacts',
accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function(){
// do things with google services
require('https').request({
host: 'www.google.com',
port: 443,
path: path,
method: 'GET',
headers: {
'Authorization': 'GoogleLogin auth=' + googleAuth.getAuthId(),
...
}
});
});
googleAuth.on(GoogleClientLogin.events.error, function(e) {
switch(e.message) {
case GoogleClientLogin.errors.loginFailed:
if (this.isCaptchaRequired()) {
requestCaptchaFromUser(this.getCaptchaUrl(), this.getCaptchaToken());
} else {
requestLoginDetailsAgain();
}
break;
case GoogleClientLogin.errors.tokenMissing:
case GoogleClientLogin.errors.captchaMissing:
throw new Error('You must pass the both captcha token and the captcha')
break;
}
throw new Error('Unknown error');
// damn..
});
googleAuth.login();

View File

@ -1,313 +0,0 @@
/*jslint indent: 2*/
/*global require: true*/
/**
* For more details about the ClientLogin authentication check out this:
* http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
*/
var EventEmitter = require('events').EventEmitter,
util = require('util');
// useragent string
const userAgent = 'GCLNodejs';
// version string
const ver = '0.2.2';
const loginURL = '/accounts/ClientLogin';
const googleHost = 'www.google.com';
const captchaRequiredError = 'CaptchaRequired';
// error messages
const errors = {
captchaMissing: 'User entered captcha is missing',
tokenMissing: 'Login token is missing',
loginFailed: 'Login failed'
};
const events = {
login: 'login',
error: 'error'
};
// Google account types
const accountTypes = {
google: 'GOOGLE', // get authorization for a Google account only
hosted: 'HOSTED', // get authorization for a hosted account only
hostedOrGoogle: 'HOSTED_OR_GOOGLE' // get authorization first for a hosted account; if attempt fails, get authorization for a Google account
};
// http://code.google.com/apis/gdata/faq.html#clientlogin
const services = {
adwords: 'adwords',
analytics: 'analytics',
apps: 'apps',
base: 'gbase',
sites: 'jotspot',
blogger: 'blogger',
book: 'print',
calendar: 'cl',
codesearch: 'codesearch',
contacts: 'cp',
docs: 'writely',
finance: 'finance',
mail: 'mail',
health: 'health',
weaver: 'weaver',
maps: 'local',
picasaweb: 'lh2',
reader: 'reader',
sidewiki: 'annotateweb',
spreadsheets: 'wise',
webmastertools: 'sitemaps',
youtube: 'youtube',
c2dm: 'ac2dm',
voice: 'grandcentral',
fusiontables: 'fusiontables'
};
/**
* Helps to log in to any google service with the clientlogin method
* Google returns 3 values when login was success:
* Auth, SID, LSID
*
* After the login you need to include the Auth value into
* the Authorization HTTP header on each request:
*
* client.request('GET', '...', {
* ...,
* 'Authorization':'GoogleLogin auth=' + googleClientLoginInstance.getAuthId()
* })
*
* @class GoogleClientLogin
* @constructor
* @param Object conf An object, with two properties: email and password
*/
var GoogleClientLogin = function (conf) {
this.conf = conf || {};
// stores the authentication data
this.auths = {};
this.loginProcessing = false;
};
GoogleClientLogin.prototype = {};
util.inherits(GoogleClientLogin, EventEmitter);
/**
* Splits response data into key-value pairs,
* Only for internal usage
* @method _parseData
*/
GoogleClientLogin.prototype._parseData = function (data) {
this.auths = {};
data.split('\n').forEach(function (dataStr) {
var data = dataStr.split('=');
this.auths[data[0]] = data[1];
}.bind(this));
};
/**
* Parses the response of the login
* emits error and login event
* @method _parseLoginResponse
* @param {http.ClientResponse} response The response object
*/
GoogleClientLogin.prototype._parseLoginResponse = function (response) {
var data = '';
response.on('data', function (chunk) {
data += chunk;
}.bind(this));
response.on('error', function (e) {
this.emit(events.error, e);
}.bind(this));
response.on('end', function () {
this.loginProcessing = false;
var statusCode = response.statusCode, error;
this._parseData(data);
if (statusCode >= 200 && statusCode < 300) {
/**
* Fires when login was success
* @event login
*/
this.emit(events.login);
} else {
/**
* Fires when login failed
* @event loginFailed
*/
error = new Error(errors.loginFailed);
error.data = data;
error.response = response;
this.emit(events.error, error);
}
}.bind(this));
};
/**
* Method to find out which account type should we use, default is HOSTED_OR_GOOGLE
* Only for internal usage
* @method _getAccountType
* @returns string
*/
GoogleClientLogin.prototype._getAccountType = function (params) {
var output = accountTypes.hostedOrGoogle;
if (typeof params === 'object' && params.accountType === 'string' &&
typeof accountTypes[params.accountType] === 'string') {
output = accountTypes[params.accountType];
} else if (typeof this.conf.accountType === 'string') {
output = accountTypes[this.conf.accountType];
}
return output;
};
/**
* Method to create the content of the login request
* Only for internal usage
* @method _getRequestContent
* @param {Object} params (Optional) You can pass the logincaptcha and
* logintoken and the accountType as properties
* @returns string
*/
GoogleClientLogin.prototype._getRequestContent = function (params) {
var output, hasCaptcha, hasToken, error;
output = {
accountType: this._getAccountType(params),
Email: this.conf.email,
Passwd: this.conf.password,
service: services[this.conf.service],
source: userAgent + '_' + ver
};
if (typeof params === 'object') {
hasCaptcha = typeof params.logincaptcha === 'string';
hasToken = typeof params.logintoken === 'string';
if (hasCaptcha && hasToken) {
output.logincaptcha = params.logincaptcha;
output.logintoken = params.logintoken;
// if the captcha or the token is given the other also required
} else if (!hasCaptcha && hasToken) {
error = errors.captchaMissing;
} else if (!hasToken && hasCaptcha) {
error = errors.tokenMissing;
}
}
if (error) {
this.emit(events.error, new Error(error));
output = false;
} else {
output = require('querystring').stringify(output);
}
return output;
};
/**
* Logs in the user
* @method login
* @param {Object} params (optional) You can pass the logincaptcha and
* logintoken and the accountType as properties
*/
GoogleClientLogin.prototype.login = function (params) {
// don't try to log in, if one is already in progress
if (!this.loginProcessing) {
this.loginProcessing = true;
var content, request;
content = this._getRequestContent(params);
if (content !== false) {
request = require('https').request(
{
host: 'www.google.com',
port: 443,
path: loginURL,
method: 'POST',
headers: {
'Content-Length': content.length,
'Content-Type': 'application/x-www-form-urlencoded'
}
},
this._parseLoginResponse.bind(this)
);
request.write(content);
request.end();
}
}
};
/**
* Method to get the AuthId property
* @method getAuthId
* @returns the AuthId or undefined
*/
GoogleClientLogin.prototype.getAuthId = function () {
return this.auths.Auth;
};
/**
* Method to ge the SID property
* @method getSID
* @returns the value of the SID property or undefined
*/
GoogleClientLogin.prototype.getSID = function () {
return this.auths.SID;
};
/**
* Method to get the LSID property
* @method getLSID
* @returns the value of the LSID property or undefined
*/
GoogleClientLogin.prototype.getLSID = function () {
return this.auths.LSID;
};
/**
* Method to get the error code
* @method getError
* @returns the error code or undefined
*/
GoogleClientLogin.prototype.getError = function () {
return this.auths.Error;
};
/**
* Method to know if captcha is required
* @method isCaptchaRequired
* @returns boolean
*/
GoogleClientLogin.prototype.isCaptchaRequired = function () {
return this.getError() === captchaRequiredError;
};
/**
* Method to get the captcha url
* @method getCaptchaUrl
* @returns the value of the CaptchaUrl property or undefined
*/
GoogleClientLogin.prototype.getCaptchaUrl = function () {
return this.auths.CaptchaUrl;
};
/**
* Returns the value of the CaptchaToken property
* @method getCaptchaToken
* @returns string or undefined
*/
GoogleClientLogin.prototype.getCaptchaToken = function () {
return this.auths.CaptchaToken;
};
GoogleClientLogin.errors = errors;
GoogleClientLogin.events = events;
GoogleClientLogin.accountTypes = accountTypes;
exports.GoogleClientLogin = GoogleClientLogin;

File diff suppressed because one or more lines are too long

View File

@ -1,57 +0,0 @@
/*global console:true, require:true*/
/*jslint indent:2*/
var assert = require('assert');
var IniReader = require('inireader').IniReader;
var GoogleClientLogin = require('../index').GoogleClientLogin;
var userini = new IniReader('/home/ajnasz/.google.ini');
var finishedTests = 0;
userini.on('fileParse', function () {
var account = this.param('account1'), googleAuth;
googleAuth = new GoogleClientLogin({
email: account.email,
password: account.password,
service: 'contacts',
accountType: account.type
});
googleAuth.on(GoogleClientLogin.events.login, function () {
assert.equal(this.getSID().length, 267, 'Something wrong with the SID length');
assert.equal(this.getLSID().length, 267, 'Something wrong with the LSID length');
assert.equal(this.getAuthId().length, 267, 'Something wrong with the AuthId length');
console.log('test 1 finished');
finishedTests++;
// do things with google services
});
googleAuth.on(GoogleClientLogin.events.error, function (e) {
assert.ok(false, 'Login failed!');
console.log('on error: ', e.message);
// damn..
});
googleAuth.login();
});
userini.load();
var googleAuth = new GoogleClientLogin({
email: 'ajnasz@gmail.com',
password: 'foobar',
service: 'contacts',
accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function () {
assert.ok(false, 'Login were success, however it should fail!');
console.log('login success');
});
googleAuth.on(GoogleClientLogin.events.error, function (e) {
assert.equal(e.message, GoogleClientLogin.errors.loginFailed);
assert.equal(this.getError(), 'BadAuthentication', 'Wrong error returned');
console.log('test 2 finished');
finishedTests++;
// damn..
});
googleAuth.login();
process.on('exit', function () {
assert.deepEqual(finishedTests, 2, 'finished tests num differs');
});

View File

@ -1,65 +0,0 @@
/*jslint indent: 2*/
/*global require: true, console: true*/
var assert = require('assert');
var pw = function () {
return 'foobar' + Date.now() + Math.random();
};
var GoogleClientLogin = require('googleclientlogin').GoogleClientLogin;
(function () {
var googleAuth = new GoogleClientLogin({
email: 'ajnasz@gmail.com',
password: pw(),
service: 'contacts',
accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function () {
console.log('login success');
});
googleAuth.on(GoogleClientLogin.events.error, function (e) {
assert.equal(e.message, GoogleClientLogin.errors.tokenMissing);
console.log('test 2 finished', JSON.stringify(this.auths), this.isCaptchaRequired());
// damn..
});
googleAuth.login({logincaptcha: 'asdf'});
}());
(function () {
var googleAuth = new GoogleClientLogin({
email: 'ajnasz@gmail.com',
password: pw(),
service: 'contacts',
accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function () {
console.log('login success');
});
googleAuth.on(GoogleClientLogin.events.error, function (e) {
assert.equal(e.message, GoogleClientLogin.errors.captchaMissing);
console.log('test 2 finished', JSON.stringify(this.auths), this.isCaptchaRequired());
// damn..
});
googleAuth.login({logintoken: 'asdf'});
}());
(function () {
var googleAuth = new GoogleClientLogin({
email: 'ajnasz@gmail.com',
password: pw(),
service: 'contacts',
accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function () {
console.log('login success');
});
googleAuth.on(GoogleClientLogin.events.error, function (e) {
console.log('test 2 finished', JSON.stringify(e.response.headers),
JSON.stringify(this.auths), this.isCaptchaRequired());
// damn..
});
googleAuth.login({logintoken: 'asdf', logincaptcha: 'askdfljasf'});
}());